diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/LoginService.java b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/LoginService.java index 1c27afa2..f0e4f075 100644 --- a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/LoginService.java +++ b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/LoginService.java @@ -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; /** diff --git a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultLoginService.java b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultLoginService.java index 956f6e2c..126c2903 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultLoginService.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultLoginService.java @@ -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()