isLogged return the user

git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1424972 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-12-21 15:32:09 +00:00
parent c818f5a22e
commit dc712ce923
2 changed files with 9 additions and 8 deletions

View 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;
/**

View 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()