]> source.dussan.org Git - archiva.git/commitdiff
isLogged return the user
authorOlivier Lamy <olamy@apache.org>
Fri, 21 Dec 2012 15:32:09 +0000 (15:32 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 21 Dec 2012 15:32:09 +0000 (15:32 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1424972 13f79535-47bb-0310-9956-ffa450edef68

redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/LoginService.java
redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultLoginService.java

index 1c27afa23c58988838652b15dc2b166e96eb5f59..f0e4f075b09e7ed2a37e52a98b670c7ab3d7b4b8 100644 (file)
@@ -71,14 +71,14 @@ public interface LoginService
         throws RedbackServiceException;
 
     /**
-     * simply check if current user has an http session opened with authz passed
+     * simply check if current user has an http session opened with authz passed and return user data
      * @since 1.4
      */
     @Path( "isLogged" )
     @GET
-    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
+    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
     @RedbackAuthorization( noRestriction = true )
-    Boolean isLogged()
+    User isLogged()
         throws RedbackServiceException;
 
     /**
index 956f6e2c049dbd52fbab3f6070a7734764048ddb..126c29033d187006b5b8340b304c26fe1ab67ca4 100644 (file)
@@ -61,7 +61,7 @@ import java.util.TimeZone;
  * @author Olivier Lamy
  * @since 1.3
  */
-@Service("loginService#rest")
+@Service( "loginService#rest" )
 public class DefaultLoginService
     implements LoginService
 {
@@ -77,7 +77,7 @@ public class DefaultLoginService
 
     @Inject
     public DefaultLoginService( SecuritySystem securitySystem,
-                                @Named("httpAuthenticator#basic") HttpAuthenticator httpAuthenticator )
+                                @Named( "httpAuthenticator#basic" ) HttpAuthenticator httpAuthenticator )
     {
         this.securitySystem = securitySystem;
         this.httpAuthenticator = httpAuthenticator;
@@ -199,12 +199,13 @@ public class DefaultLoginService
 
     }
 
-    public Boolean isLogged()
+    public User isLogged()
         throws RedbackServiceException
     {
-        Boolean isLogged = httpAuthenticator.getSecuritySession( httpServletRequest.getSession( true ) ) != null;
+        SecuritySession securitySession = httpAuthenticator.getSecuritySession( httpServletRequest.getSession( true ) );
+        Boolean isLogged = securitySession != null;
         log.debug( "isLogged {}", isLogged );
-        return isLogged;
+        return isLogged ? buildRestUser( securitySession.getUser() ) : null;
     }
 
     public Boolean logout()