Index: DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/nb-configuration.xml
===================================================================
--- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/nb-configuration.xml	(revision 4969)
+++ 	(revision )
@@ -1,18 +1,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project-shared-configuration>
-    <!--
-This file contains additional configuration written by modules in the NetBeans IDE.
-The configuration is intended to be shared among all the users of project and
-therefore it is assumed to be part of version control checkout.
-Without this configuration present, some functionality in the IDE may be limited or fail altogether.
--->
-    <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
-        <!--
-Properties that influence various parts of the IDE, especially code formatting and the like. 
-You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
-That way multiple projects can share the same settings (useful for formatting rules for example).
-Any value defined here will override the pom.xml file value but is only applicable to the current project.
--->
-        <org-netbeans-modules-maven-jaxws.rest_2e_config_2e_type>user</org-netbeans-modules-maven-jaxws.rest_2e_config_2e_type>
-    </properties>
-</project-shared-configuration>
Index: DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/pom.xml
===================================================================
--- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/pom.xml	(revision 4969)
+++ DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/pom.xml	(revision 4985)
@@ -16,4 +16,16 @@
     <dependencies>
         <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <version>3.0.1</version>
+            <scope>provided</scope>            
+        </dependency>  
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <version>2.5</version>
+            <scope>provided</scope>
+        </dependency>        
+        <dependency>
             <groupId>com.sun.jersey</groupId>
             <artifactId>jersey-servlet</artifactId>
@@ -36,4 +48,10 @@
             <artifactId>jersey-test-framework-grizzly2</artifactId>
             <version>${jersey.version}</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>javax.servlet</artifactId>
+                    <groupId>org.glassfish</groupId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
@@ -70,4 +88,19 @@
         </dependency>
         <dependency>
+            <groupId>org.springframework.security</groupId>
+            <artifactId>spring-security-config</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.security</groupId>
+            <artifactId>spring-security-web</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.security</groupId>
+            <artifactId>spring-security-core</artifactId>      
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
             <groupId>org.hsqldb</groupId>
             <artifactId>hsqldb</artifactId>
@@ -108,11 +141,4 @@
             <version>${slf4j.version}</version>
         </dependency>
-<!--        <dependency>
-            <groupId>javax.servlet</groupId>
-            <artifactId>servlet-api</artifactId>
-            <version>2.5</version>
-            <scope>provided</scope>
-        </dependency>     
-    -->
         <dependency>
             <groupId>de.mpg.mpgaai</groupId>
Index: DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/DBIntegrityService.java
===================================================================
--- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/DBIntegrityService.java	(revision 4969)
+++ DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/DBIntegrityService.java	(revision 4985)
@@ -322,5 +322,5 @@
     boolean createAnnotationInNotebook(Number notebookID, Annotation annotation, Number ownerID) throws NotInDataBaseException;
 
-    public Principal createShibbolizedPrincipal(String remoteID);
+    public Principal createPrincipalRecord(String remoteID);
     
     /**
Index: DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/DBIntegrityServiceImlp.java
===================================================================
--- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/DBIntegrityServiceImlp.java	(revision 4969)
+++ DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/DBIntegrityServiceImlp.java	(revision 4985)
@@ -851,5 +851,5 @@
 
     @Override
-    public Principal createShibbolizedPrincipal(String remoteID) {
+    public Principal createPrincipalRecord(String remoteID) {
         return principalDao.createShibbolizedPrincipal(remoteID);
     }
Index: DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AutheticationResource.java
===================================================================
--- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AutheticationResource.java	(revision 4969)
+++ DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AutheticationResource.java	(revision 4985)
@@ -22,5 +22,5 @@
 import eu.dasish.annotation.schema.Principal;
 import java.io.IOException;
-import java.sql.SQLException;
+import javax.servlet.ServletException;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
@@ -38,6 +38,8 @@
 @Component
 @Path("/authentication")
-@Transactional(rollbackFor = {Exception.class, SQLException.class, IOException.class, ParserConfigurationException.class})
+@Transactional(rollbackFor = {Exception.class, IOException.class, ParserConfigurationException.class})
 public class AutheticationResource extends ResourceResource {
+
+  
 
     @GET
@@ -65,14 +67,11 @@
     }
 
-
-
     @GET
     @Produces(MediaType.TEXT_XML)
     @Path("logout")
     @Transactional(readOnly = true)
-    public void logout() throws IOException {
+    public void logout() throws IOException, ServletException {
+        httpServletRequest.getSession().invalidate();
         httpServletResponse.sendRedirect(context.getInitParameter("eu.dasish.annotation.backend.logout"));
     }
-
-    
 }
Index: DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/DebugResource.java
===================================================================
--- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/DebugResource.java	(revision 4969)
+++ DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/DebugResource.java	(revision 4985)
@@ -92,5 +92,5 @@
     @Transactional(readOnly = true)
     public String getLoggedInRemoteID() {
-        return httpServletRequest.getRemoteUser();
+        return (httpServletRequest.getRemoteUser() != null) ? httpServletRequest.getRemoteUser() : "Null";
     }
 
Index: DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/ResourceResource.java
===================================================================
--- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/ResourceResource.java	(revision 4969)
+++ DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/ResourceResource.java	(revision 4985)
@@ -61,27 +61,33 @@
         String remotePrincipal = httpServletRequest.getRemoteUser();
         verboseOutput = new VerboseOutput(loggerServer);
-        if (!remotePrincipal.equals("anonymous")) {
-            try {
-                return dbIntegrityService.getPrincipalInternalIDFromRemoteID(remotePrincipal);
-            } catch (NotInDataBaseException e) {
-                loggerServer.info(e.toString());
-                loggerServer.info("The record for the user with the Shibboleth id " + remotePrincipal + " will be generated now automatically.");
+        if (remotePrincipal != null) {
+            if (!remotePrincipal.equals("anonymous")) {
                 try {
+                    return dbIntegrityService.getPrincipalInternalIDFromRemoteID(remotePrincipal);
+                } catch (NotInDataBaseException e) {
+                    loggerServer.info(e.toString());
+                    loggerServer.info("The record for the user with the Shibboleth id " + remotePrincipal + " will be generated now automatically.");
                     try {
-                        return dbIntegrityService.addPrincipal(dbIntegrityService.createShibbolizedPrincipal(remotePrincipal), remotePrincipal);
-                    } catch (PrincipalExists e2) {
-                        loggerServer.info(e2.toString());
-                        httpServletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e2.toString());
+                        try {
+                            return dbIntegrityService.addPrincipal(dbIntegrityService.createPrincipalRecord(remotePrincipal), remotePrincipal);
+                        } catch (PrincipalExists e2) {
+                            loggerServer.info(e2.toString());
+                            httpServletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e2.toString());
+                            return null;
+                        }
+                    } catch (NotInDataBaseException e1) {
+                        loggerServer.info(e1.toString());
+                        httpServletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e1.toString());
                         return null;
                     }
-                } catch (NotInDataBaseException e1) {
-                    loggerServer.info(e1.toString());
-                    httpServletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e1.toString());
-                    return null;
                 }
+            } else {
+                loggerServer.info("Shibboleth fall-back.  Logged in as 'anonymous' with no rights.");
+                httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, " Shibboleth fall-back.  Logged in as 'anonymous' with no rights.");
+                return null;
             }
         } else {
-            loggerServer.info("Shibboleth fall-back.  Logged in as 'anonymous' with no rights.");
-            httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, " Shibboleth fall-back.  Logged in as 'anonymous' with no rights.");
+            loggerServer.info("Null principal");
+            httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, " Null principal");
             return null;
         }
Index: DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/resources/spring-config/springSecurity.xml
===================================================================
--- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/resources/spring-config/springSecurity.xml	(revision 4985)
+++ DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/resources/spring-config/springSecurity.xml	(revision 4985)
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    
+    Copyright (C) 2013 DASISH
+    
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License
+    as published by the Free Software Foundation; either version 2
+    of the License, or (at your option) any later version.
+    
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+    GNU General Public License for more details.
+    
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+    
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+    xmlns:security="http://www.springframework.org/schema/security"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://www.springframework.org/schema/beans
+    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+    http://www.springframework.org/schema/security
+    http://www.springframework.org/schema/security/spring-security-3.2.xsd">     
+    <security:http auto-config='true'>
+        <security:intercept-url pattern="/api/authentication/login" access="ROLE_USER" />
+        <security:http-basic />
+        <security:logout delete-cookies="JSESSIONID"/>
+    </security:http>
+    <security:authentication-manager>
+        <security:authentication-provider>
+            <security:user-service>
+                <security:user name="olhsha" password="olhapassword" authorities="ROLE_USER, ROLE_ADMIN" />
+            </security:user-service>
+        </security:authentication-provider>
+    </security:authentication-manager>   
+</beans>
+
+
+
Index: DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/webapp/WEB-INF/web.xml
===================================================================
--- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/webapp/WEB-INF/web.xml	(revision 4969)
+++ DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/webapp/WEB-INF/web.xml	(revision 4985)
@@ -35,5 +35,5 @@
         <param-name>eu.dasish.annotation.backend.schemaLocation</param-name>
         <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>
-    <!-- <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> -->
+        <!-- <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> -->
     </context-param>
     <context-param>
@@ -47,5 +47,7 @@
     <context-param>
         <param-name>eu.dasish.annotation.backend.logout</param-name>
-        <param-value>/ds/webannotator?shhaaDo=lO</param-value>
+        <!-- <param-value>/ds/webannotator?shhaaDo=lO</param-value> -->
+        <!-- <param-value>/ds/webannotator/j_spring_security_logout</param-value> -->
+        <param-value>/annotator-backend/j_spring_security_logout</param-value>
     </context-param>
     
@@ -82,5 +84,5 @@
     </servlet-mapping>
     
-<!--   <security-constraint>
+    <!--   <security-constraint>
         <display-name>Protected backend localhost</display-name>
         <web-resource-collection>
@@ -105,6 +107,17 @@
         <role-name>tomcat</role-name>
     </security-role> -->
-    
+   
+ <!-- Spring security -->
     <filter>
+        <filter-name>springSecurityFilterChain</filter-name>
+        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
+    </filter>
+    <filter-mapping>
+        <filter-name>springSecurityFilterChain</filter-name>
+        <url-pattern>/*</url-pattern>
+    </filter-mapping>
+       
+    <!--  Shibboleth filter -->
+<!--    <filter>
         <filter-name>AAIFilter</filter-name>
         <filter-class>de.mpg.aai.shhaa.AuthFilter</filter-class>
@@ -113,5 +126,5 @@
         <filter-name>AAIFilter</filter-name>
         <url-pattern>/*</url-pattern>
-    </filter-mapping> 
+    </filter-mapping> -->
     
    
