|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.atlassian.seraph.auth.AbstractAuthenticator
com.atlassian.seraph.auth.DefaultAuthenticator
public abstract class DefaultAuthenticator
This authenticator stores the currently logged in user in the session as a Principal.
It also provides for cookie logins and creates cookies if needed. Includes code from Jive 1.2.4 (released under the Apache license)
| Field Summary | |
|---|---|
static java.lang.String |
LOGGED_IN_KEY
The key used to store the user object in the session |
static java.lang.String |
LOGGED_OUT_KEY
The key used to indicate that the user has logged out and session regarding of it containing a cookie is not logged in. |
| Fields inherited from interface com.atlassian.seraph.auth.Authenticator |
|---|
DEFAULT_AUTHENTICATOR |
| Constructor Summary | |
|---|---|
DefaultAuthenticator()
|
|
| Method Summary | |
|---|---|
protected abstract boolean |
authenticate(java.security.Principal user,
java.lang.String password)
Authenticates the given user and password. |
protected boolean |
authoriseUserAndEstablishSession(javax.servlet.http.HttpServletRequest httpServletRequest,
javax.servlet.http.HttpServletResponse httpServletResponse,
java.security.Principal principal)
This is called to authorise the user with the application. |
java.lang.String |
getAuthType()
|
protected ElevatedSecurityGuard |
getElevatedSecurityGuard()
|
protected java.util.List<LogoutInterceptor> |
getLogoutInterceptors()
|
protected RememberMeService |
getRememberMeService()
|
protected RoleMapper |
getRoleMapper()
override this method if you need to retrieve the role mapper from elsewhere than the singleton-factory (injected dependency for instance) |
java.security.Principal |
getUser(javax.servlet.http.HttpServletRequest httpServletRequest,
javax.servlet.http.HttpServletResponse httpServletResponse)
Returns the currently logged in user, trying in order: Session, only if one exists Cookie, only if no session exists Basic authentication, if the above fail, and authType=basic Warning: only in the case of cookie and basic auth will the user be authenticated. |
protected abstract java.security.Principal |
getUser(java.lang.String username)
Retrieve a Principal for the given username. |
protected java.security.Principal |
getUserFromBasicAuthentication(javax.servlet.http.HttpServletRequest httpServletRequest,
javax.servlet.http.HttpServletResponse httpServletResponse)
Checks the Authorization header to see whether basic auth token is provided. |
protected java.security.Principal |
getUserFromCookie(javax.servlet.http.HttpServletRequest httpServletRequest,
javax.servlet.http.HttpServletResponse httpServletResponse)
Extracts the username and password from the cookie and calls login to authenticate, and if successful store the token in the session. |
protected java.security.Principal |
getUserFromSession(javax.servlet.http.HttpServletRequest httpServletRequest)
Tries to get a logged in user from the session. |
void |
init(java.util.Map<java.lang.String,java.lang.String> params,
SecurityConfig config)
Initialise the configuration object with the given "init-params". |
protected boolean |
isAuthorised(javax.servlet.http.HttpServletRequest httpServletRequest,
java.security.Principal principal)
This method is called to estblish if the principal is authorised to use the appliction url in play |
protected boolean |
isPrincipalAlreadyInSessionContext(javax.servlet.http.HttpServletRequest httpServletRequest,
java.security.Principal principal)
This is called to determine if the Principal is already in the HttpSession in a Seraph ready manner. |
boolean |
isUserInRole(javax.servlet.http.HttpServletRequest request,
java.lang.String role)
Deprecated. Use RoleMapper directly |
boolean |
login(javax.servlet.http.HttpServletRequest httpServletRequest,
javax.servlet.http.HttpServletResponse httpServletResponse,
java.lang.String userName,
java.lang.String password,
boolean setRememberMeCookie)
Tries to authenticate a user. |
boolean |
logout(javax.servlet.http.HttpServletRequest httpServletRequest,
javax.servlet.http.HttpServletResponse httpServletResponse)
Called to remove the current principal from the HttpSession and will also to remove any remember me cookies that may be in effect. |
protected void |
putPrincipalInSessionContext(javax.servlet.http.HttpServletRequest httpServletRequest,
java.security.Principal principal)
This can be called to put the principal into the HttpSession in a Seraph ready manner |
protected java.security.Principal |
refreshPrincipalObtainedFromSession(javax.servlet.http.HttpServletRequest httpServletRequest,
java.security.Principal principal)
This is called to refresh the Principal object that has been retreived from the HTTP session. |
protected void |
removePrincipalFromSessionContext(javax.servlet.http.HttpServletRequest httpServletRequest)
This can be called to remove the principal into the HttpSession in a Seraph ready manner |
| Methods inherited from class com.atlassian.seraph.auth.AbstractAuthenticator |
|---|
destroy, getConfig, getRemoteUser, getUser, login |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String LOGGED_IN_KEY
public static final java.lang.String LOGGED_OUT_KEY
| Constructor Detail |
|---|
public DefaultAuthenticator()
| Method Detail |
|---|
public void init(java.util.Map<java.lang.String,java.lang.String> params,
SecurityConfig config)
Initable
init in interface Initableinit in class AbstractAuthenticatorparams - The map of "init-params" extracted from the Seraph config file. This is guaranteed not null.config - The Seraph SecurityConfig class that is initialising the config objects. This object will only be partially initialised at this time.
@Deprecated
public boolean isUserInRole(javax.servlet.http.HttpServletRequest request,
java.lang.String role)
RoleMapper directly
isUserInRole in interface AuthenticatorisUserInRole in class AbstractAuthenticator
public boolean login(javax.servlet.http.HttpServletRequest httpServletRequest,
javax.servlet.http.HttpServletResponse httpServletResponse,
java.lang.String userName,
java.lang.String password,
boolean setRememberMeCookie)
throws AuthenticatorException
login in interface Authenticatorlogin in class AbstractAuthenticatorhttpServletRequest - the request in playhttpServletResponse - the response in playuserName - the user name to check against the passwordpassword - the password to authenticate the user withsetRememberMeCookie - whether to set a remember me cookie on sucessful login
AuthenticatorException - actualy this class does not throw any exceptions however the interface says we
must and other classes may override us
public boolean logout(javax.servlet.http.HttpServletRequest httpServletRequest,
javax.servlet.http.HttpServletResponse httpServletResponse)
throws AuthenticatorException
logout in interface Authenticatorlogout in class AbstractAuthenticatorhttpServletRequest - the request in playhttpServletResponse - the response in play
AuthenticatorException - this implementation never does
protected boolean authoriseUserAndEstablishSession(javax.servlet.http.HttpServletRequest httpServletRequest,
javax.servlet.http.HttpServletResponse httpServletResponse,
java.security.Principal principal)
RoleMapper is invoked to see if the user
is authorised to user this request via a call to isAuthorised(javax.servlet.http.HttpServletRequest,
java.security.Principal)
If successful, then the HttpSession will contain the attribute marking that the user is logged in
httpServletRequest - the request in playhttpServletResponse - the response in playprincipal - the principal to authorise
protected boolean isAuthorised(javax.servlet.http.HttpServletRequest httpServletRequest,
java.security.Principal principal)
httpServletRequest - the request in playprincipal - the principal to check
protected void putPrincipalInSessionContext(javax.servlet.http.HttpServletRequest httpServletRequest,
java.security.Principal principal)
httpServletRequest - the request in playprincipal - the principal to put in the sessionprotected void removePrincipalFromSessionContext(javax.servlet.http.HttpServletRequest httpServletRequest)
httpServletRequest - the request in play
protected boolean isPrincipalAlreadyInSessionContext(javax.servlet.http.HttpServletRequest httpServletRequest,
java.security.Principal principal)
httpServletRequest - the request in playprincipal - the principal to put in the session
protected RoleMapper getRoleMapper()
RoleMapper to useprotected abstract java.security.Principal getUser(java.lang.String username)
username - the name of the user to find
protected abstract boolean authenticate(java.security.Principal user,
java.lang.String password)
throws AuthenticatorException
user - the user to authenticate. This object only stores the username of the user.password - the password of the user
AuthenticatorException - if an error occurs that stops the user from being authenticated (eg remote communication failure).
public java.security.Principal getUser(javax.servlet.http.HttpServletRequest httpServletRequest,
javax.servlet.http.HttpServletResponse httpServletResponse)
getUser in interface AuthenticatorgetUser in class AbstractAuthenticatorhttpServletRequest - the request in playhttpServletResponse - a response object that may be modified if basic auth is enabled
protected java.security.Principal refreshPrincipalObtainedFromSession(javax.servlet.http.HttpServletRequest httpServletRequest,
java.security.Principal principal)
getUser(String) again to get a fresh user.
httpServletRequest - the HTTP request in playprincipal - the Principal in play
protected java.security.Principal getUserFromSession(javax.servlet.http.HttpServletRequest httpServletRequest)
Tries to get a logged in user from the session.
httpServletRequest - the current HttpServletRequest
null if there is no logged in user in the session, or the
LOGGED_OUT_KEY is set because the user has logged out.
protected java.security.Principal getUserFromCookie(javax.servlet.http.HttpServletRequest httpServletRequest,
javax.servlet.http.HttpServletResponse httpServletResponse)
httpServletRequest - the HTTP request in playhttpServletResponse - the HTTP respone in play
protected java.security.Principal getUserFromBasicAuthentication(javax.servlet.http.HttpServletRequest httpServletRequest,
javax.servlet.http.HttpServletResponse httpServletResponse)
httpServletRequest - the HTTP request in playhttpServletResponse - a response object that will be modified if no token found
Principal or null if one cant be foundpublic java.lang.String getAuthType()
protected java.util.List<LogoutInterceptor> getLogoutInterceptors()
protected ElevatedSecurityGuard getElevatedSecurityGuard()
protected RememberMeService getRememberMeService()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||