Changeset 4985


Ignore:
Timestamp:
04/15/14 17:36:50 (10 years ago)
Author:
olhsha@mpi.nl
Message:

restored simple spring authentication

Location:
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend
Files:
1 added
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/pom.xml

    r4969 r4985  
    1616    <dependencies>
    1717        <dependency>
     18            <groupId>javax.servlet</groupId>
     19            <artifactId>javax.servlet-api</artifactId>
     20            <version>3.0.1</version>
     21            <scope>provided</scope>           
     22        </dependency> 
     23        <dependency>
     24            <groupId>javax.servlet</groupId>
     25            <artifactId>servlet-api</artifactId>
     26            <version>2.5</version>
     27            <scope>provided</scope>
     28        </dependency>       
     29        <dependency>
    1830            <groupId>com.sun.jersey</groupId>
    1931            <artifactId>jersey-servlet</artifactId>
     
    3648            <artifactId>jersey-test-framework-grizzly2</artifactId>
    3749            <version>${jersey.version}</version>
     50            <exclusions>
     51                <exclusion>
     52                    <artifactId>javax.servlet</artifactId>
     53                    <groupId>org.glassfish</groupId>
     54                </exclusion>
     55            </exclusions>
    3856        </dependency>
    3957        <dependency>
     
    7088        </dependency>
    7189        <dependency>
     90            <groupId>org.springframework.security</groupId>
     91            <artifactId>spring-security-config</artifactId>
     92            <version>${spring.version}</version>
     93        </dependency>
     94        <dependency>
     95            <groupId>org.springframework.security</groupId>
     96            <artifactId>spring-security-web</artifactId>
     97            <version>${spring.version}</version>
     98        </dependency>
     99        <dependency>
     100            <groupId>org.springframework.security</groupId>
     101            <artifactId>spring-security-core</artifactId>     
     102            <version>${spring.version}</version>
     103        </dependency>
     104        <dependency>
    72105            <groupId>org.hsqldb</groupId>
    73106            <artifactId>hsqldb</artifactId>
     
    108141            <version>${slf4j.version}</version>
    109142        </dependency>
    110 <!--        <dependency>
    111             <groupId>javax.servlet</groupId>
    112             <artifactId>servlet-api</artifactId>
    113             <version>2.5</version>
    114             <scope>provided</scope>
    115         </dependency>     
    116     -->
    117143        <dependency>
    118144            <groupId>de.mpg.mpgaai</groupId>
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/DBIntegrityService.java

    r4941 r4985  
    322322    boolean createAnnotationInNotebook(Number notebookID, Annotation annotation, Number ownerID) throws NotInDataBaseException;
    323323
    324     public Principal createShibbolizedPrincipal(String remoteID);
     324    public Principal createPrincipalRecord(String remoteID);
    325325   
    326326    /**
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/DBIntegrityServiceImlp.java

    r4941 r4985  
    851851
    852852    @Override
    853     public Principal createShibbolizedPrincipal(String remoteID) {
     853    public Principal createPrincipalRecord(String remoteID) {
    854854        return principalDao.createShibbolizedPrincipal(remoteID);
    855855    }
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AutheticationResource.java

    r4969 r4985  
    2222import eu.dasish.annotation.schema.Principal;
    2323import java.io.IOException;
    24 import java.sql.SQLException;
     24import javax.servlet.ServletException;
    2525import javax.ws.rs.GET;
    2626import javax.ws.rs.Path;
     
    3838@Component
    3939@Path("/authentication")
    40 @Transactional(rollbackFor = {Exception.class, SQLException.class, IOException.class, ParserConfigurationException.class})
     40@Transactional(rollbackFor = {Exception.class, IOException.class, ParserConfigurationException.class})
    4141public class AutheticationResource extends ResourceResource {
     42
     43 
    4244
    4345    @GET
     
    6567    }
    6668
    67 
    68 
    6969    @GET
    7070    @Produces(MediaType.TEXT_XML)
    7171    @Path("logout")
    7272    @Transactional(readOnly = true)
    73     public void logout() throws IOException {
     73    public void logout() throws IOException, ServletException {
     74        httpServletRequest.getSession().invalidate();
    7475        httpServletResponse.sendRedirect(context.getInitParameter("eu.dasish.annotation.backend.logout"));
    7576    }
    76 
    77    
    7877}
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/DebugResource.java

    r4969 r4985  
    9292    @Transactional(readOnly = true)
    9393    public String getLoggedInRemoteID() {
    94         return httpServletRequest.getRemoteUser();
     94        return (httpServletRequest.getRemoteUser() != null) ? httpServletRequest.getRemoteUser() : "Null";
    9595    }
    9696
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/ResourceResource.java

    r4969 r4985  
    6161        String remotePrincipal = httpServletRequest.getRemoteUser();
    6262        verboseOutput = new VerboseOutput(loggerServer);
    63         if (!remotePrincipal.equals("anonymous")) {
    64             try {
    65                 return dbIntegrityService.getPrincipalInternalIDFromRemoteID(remotePrincipal);
    66             } catch (NotInDataBaseException e) {
    67                 loggerServer.info(e.toString());
    68                 loggerServer.info("The record for the user with the Shibboleth id " + remotePrincipal + " will be generated now automatically.");
     63        if (remotePrincipal != null) {
     64            if (!remotePrincipal.equals("anonymous")) {
    6965                try {
     66                    return dbIntegrityService.getPrincipalInternalIDFromRemoteID(remotePrincipal);
     67                } catch (NotInDataBaseException e) {
     68                    loggerServer.info(e.toString());
     69                    loggerServer.info("The record for the user with the Shibboleth id " + remotePrincipal + " will be generated now automatically.");
    7070                    try {
    71                         return dbIntegrityService.addPrincipal(dbIntegrityService.createShibbolizedPrincipal(remotePrincipal), remotePrincipal);
    72                     } catch (PrincipalExists e2) {
    73                         loggerServer.info(e2.toString());
    74                         httpServletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e2.toString());
     71                        try {
     72                            return dbIntegrityService.addPrincipal(dbIntegrityService.createPrincipalRecord(remotePrincipal), remotePrincipal);
     73                        } catch (PrincipalExists e2) {
     74                            loggerServer.info(e2.toString());
     75                            httpServletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e2.toString());
     76                            return null;
     77                        }
     78                    } catch (NotInDataBaseException e1) {
     79                        loggerServer.info(e1.toString());
     80                        httpServletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e1.toString());
    7581                        return null;
    7682                    }
    77                 } catch (NotInDataBaseException e1) {
    78                     loggerServer.info(e1.toString());
    79                     httpServletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e1.toString());
    80                     return null;
    8183                }
     84            } else {
     85                loggerServer.info("Shibboleth fall-back.  Logged in as 'anonymous' with no rights.");
     86                httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, " Shibboleth fall-back.  Logged in as 'anonymous' with no rights.");
     87                return null;
    8288            }
    8389        } else {
    84             loggerServer.info("Shibboleth fall-back.  Logged in as 'anonymous' with no rights.");
    85             httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, " Shibboleth fall-back.  Logged in as 'anonymous' with no rights.");
     90            loggerServer.info("Null principal");
     91            httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, " Null principal");
    8692            return null;
    8793        }
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/webapp/WEB-INF/web.xml

    r4969 r4985  
    3535        <param-name>eu.dasish.annotation.backend.schemaLocation</param-name>
    3636        <param-value>http://www.dasish.eu/ns/addit https://svn.clarin.eu/DASISH/t5.6/schema/trunk/annotator-schema/src/main/resources/DASISH-schema.xsd</param-value>
    37     <!-- <param-value>http://www.dasish.eu/ns/addit file:/Users/olhsha/repositories/DASISH/t5.6/schema/trunk/annotator-schema/src/main/target/DASISH-schema.xsd</param-value> -->
     37        <!-- <param-value>http://www.dasish.eu/ns/addit file:/Users/olhsha/repositories/DASISH/t5.6/schema/trunk/annotator-schema/src/main/target/DASISH-schema.xsd</param-value> -->
    3838    </context-param>
    3939    <context-param>
     
    4747    <context-param>
    4848        <param-name>eu.dasish.annotation.backend.logout</param-name>
    49         <param-value>/ds/webannotator?shhaaDo=lO</param-value>
     49        <!-- <param-value>/ds/webannotator?shhaaDo=lO</param-value> -->
     50        <!-- <param-value>/ds/webannotator/j_spring_security_logout</param-value> -->
     51        <param-value>/annotator-backend/j_spring_security_logout</param-value>
    5052    </context-param>
    5153   
     
    8284    </servlet-mapping>
    8385   
    84 <!--   <security-constraint>
     86    <!--   <security-constraint>
    8587        <display-name>Protected backend localhost</display-name>
    8688        <web-resource-collection>
     
    105107        <role-name>tomcat</role-name>
    106108    </security-role> -->
    107    
     109   
     110 <!-- Spring security -->
    108111    <filter>
     112        <filter-name>springSecurityFilterChain</filter-name>
     113        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
     114    </filter>
     115    <filter-mapping>
     116        <filter-name>springSecurityFilterChain</filter-name>
     117        <url-pattern>/*</url-pattern>
     118    </filter-mapping>
     119       
     120    <!--  Shibboleth filter -->
     121<!--    <filter>
    109122        <filter-name>AAIFilter</filter-name>
    110123        <filter-class>de.mpg.aai.shhaa.AuthFilter</filter-class>
     
    113126        <filter-name>AAIFilter</filter-name>
    114127        <url-pattern>/*</url-pattern>
    115     </filter-mapping>
     128    </filter-mapping> -->
    116129   
    117130   
Note: See TracChangeset for help on using the changeset viewer.