|
|||||||||||
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
This authenticator stores the currently logged in user in the session as OSUser User objects.
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 boolean |
authenticate(java.security.Principal user,
java.lang.String password)
Uses OSUser's authenticate() to authenticate a user. |
protected java.lang.String[] |
decodeCookie(java.lang.String value)
|
protected java.lang.String |
encodeCookie(java.lang.String username,
java.lang.String password)
|
java.lang.String |
getAuthType()
|
protected java.lang.String |
getCookiePath(javax.servlet.http.HttpServletRequest request)
Root the login cookie at the same location as the webapp. |
protected java.lang.String |
getLoginCookieKey()
|
protected java.lang.String |
getLoginCookiePath()
|
protected java.util.List |
getLogoutInterceptors()
|
protected RoleMapper |
getRoleMapper()
|
java.security.Principal |
getUser(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
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 java.security.Principal |
getUser(java.lang.String username)
Uses OSUser to retrieve a Principal for a given username. |
protected java.security.Principal |
getUserFromBasicAuthentication(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Checks the Authorization header to see whether basic auth token is provided. |
protected java.security.Principal |
getUserFromCookie(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
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 request)
Tries to get a logged in user from the session. |
void |
init(java.util.Map params,
SecurityConfig config)
|
boolean |
isUserInRole(javax.servlet.http.HttpServletRequest request,
java.lang.String role)
Deprecated. Use RoleMapper directly |
boolean |
login(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.String username,
java.lang.String password,
boolean cookie)
Tries to authenticate a user (via OSUser). |
boolean |
logout(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
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 params, SecurityConfig config)
init
in interface Initable
init
in class AbstractAuthenticator
public boolean isUserInRole(javax.servlet.http.HttpServletRequest request, java.lang.String role)
RoleMapper
directly
isUserInRole
in interface Authenticator
isUserInRole
in class AbstractAuthenticator
public boolean login(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String username, java.lang.String password, boolean cookie) throws AuthenticatorException
login
in interface Authenticator
login
in class AbstractAuthenticator
AuthenticatorException
protected RoleMapper getRoleMapper()
protected java.security.Principal getUser(java.lang.String username)
protected boolean authenticate(java.security.Principal user, java.lang.String password)
public boolean logout(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws AuthenticatorException
logout
in interface Authenticator
logout
in class AbstractAuthenticator
AuthenticatorException
public java.security.Principal getUser(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
getUser
in interface Authenticator
getUser
in class AbstractAuthenticator
response
- a response object that may be modified if basic auth is enabled
protected java.security.Principal getUserFromCookie(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
protected java.security.Principal getUserFromSession(javax.servlet.http.HttpServletRequest request)
Tries to get a logged in user from the session.
request
- 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 getUserFromBasicAuthentication(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
response
- a response object that will be modified if no token foundprotected java.lang.String getCookiePath(javax.servlet.http.HttpServletRequest request)
protected java.lang.String getLoginCookieKey()
public java.lang.String getAuthType()
protected java.util.List getLogoutInterceptors()
protected java.lang.String encodeCookie(java.lang.String username, java.lang.String password)
protected java.lang.String[] decodeCookie(java.lang.String value)
protected java.lang.String getLoginCookiePath()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |