|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.caucho.server.security.AbstractAuthenticator
public class AbstractAuthenticator
All applications should extend AbstractAuthenticator to implement their custom authenticators. While this isn't absolutely required, it protects implementations from API changes.
The AbstractAuthenticator provides a single-signon cache. Users logged into one web-app will share the same principal.
| Field Summary | |
|---|---|
protected PasswordDigest |
_passwordDigest
|
protected java.lang.String |
_passwordDigestAlgorithm
|
protected java.lang.String |
_passwordDigestRealm
|
protected LruCache<java.lang.String,com.caucho.server.security.AbstractAuthenticator.PrincipalEntry> |
_principalCache
|
protected int |
_principalCacheSize
|
static java.lang.String |
LOGIN_NAME
|
| Constructor Summary | |
|---|---|
AbstractAuthenticator()
|
|
| Method Summary | |
|---|---|
void |
addRoleMapping(java.security.Principal principal,
java.lang.String role)
Adds a role mapping. |
protected byte[] |
digest(java.lang.String value)
|
protected java.lang.String |
getDigestPassword(HttpServletRequest request,
HttpServletResponse response,
ServletContext application,
java.lang.String username,
java.lang.String realm)
Returns the password for authenticators too lazy to calculate the digest. |
protected byte[] |
getDigestSecret(HttpServletRequest request,
HttpServletResponse response,
ServletContext application,
java.lang.String username,
java.lang.String realm,
java.lang.String algorithm)
Returns the digest secret for Digest authentication. |
boolean |
getLogoutOnSessionTimeout()
Returns true if the user should be logged out on a session timeout. |
PasswordDigest |
getPasswordDigest()
Returns the password digest |
java.lang.String |
getPasswordDigest(HttpServletRequest request,
HttpServletResponse response,
ServletContext app,
java.lang.String user,
java.lang.String password)
Returns the digest view of the password. |
java.lang.String |
getPasswordDigestAlgorithm()
Returns the password digest algorithm |
java.lang.String |
getPasswordDigestRealm()
Returns the password digest realm |
int |
getPrincipalCacheSize()
Returns the size of the principal cache. |
java.security.Principal |
getUserPrincipal(HttpServletRequest request,
HttpServletResponse response,
ServletContext application)
Grab the user from the request, assuming the user has already logged in. |
protected java.security.Principal |
getUserPrincipalImpl(HttpServletRequest request,
ServletContext application)
Gets the user from a persistent cookie, uaing authenticateCookie to actually look the cookie up. |
void |
init()
Initialize the authenticator with the application. |
boolean |
isUserInRole(HttpServletRequest request,
HttpServletResponse response,
ServletContext application,
java.security.Principal user,
java.lang.String role)
Returns true if the user plays the named role. |
java.security.Principal |
login(HttpServletRequest request,
HttpServletResponse response,
ServletContext app,
java.lang.String user,
java.lang.String password)
Logs the user in with any appropriate password. |
java.security.Principal |
loginDigest(HttpServletRequest request,
HttpServletResponse response,
ServletContext app,
java.lang.String user,
java.lang.String realm,
java.lang.String nonce,
java.lang.String uri,
java.lang.String qop,
java.lang.String nc,
java.lang.String cnonce,
byte[] clientDigest)
Validates the user when using HTTP Digest authentication. |
java.security.Principal |
loginDigestImpl(HttpServletRequest request,
HttpServletResponse response,
ServletContext app,
java.lang.String user,
java.lang.String realm,
java.lang.String nonce,
java.lang.String uri,
java.lang.String qop,
java.lang.String nc,
java.lang.String cnonce,
byte[] clientDigest)
Validates the user when HTTP Digest authentication. |
protected java.security.Principal |
loginImpl(HttpServletRequest request,
HttpServletResponse response,
ServletContext application,
java.lang.String user,
java.lang.String password)
Authenticate (login) the user. |
void |
logout(HttpServletRequest request,
HttpServletResponse response,
ServletContext application,
java.security.Principal user)
Deprecated. |
void |
logout(ServletContext application,
HttpSession timeoutSession,
java.lang.String sessionId,
java.security.Principal user)
Logs the user out from the session. |
void |
logout(ServletContext application,
java.lang.String sessionId,
java.security.Principal user)
Deprecated. |
void |
setLogoutOnSessionTimeout(boolean logout)
Sets true if the principal should logout when the session times out. |
void |
setPasswordDigest(PasswordDigest digest)
Sets the password digest. |
void |
setPasswordDigestAlgorithm(java.lang.String digest)
Sets the password digest algorithm. |
void |
setPasswordDigestRealm(java.lang.String realm)
Sets the password digest realm. |
void |
setPrincipalCacheSize(int size)
Sets the size of the principal cache. |
void |
setSerializationHandle(java.lang.Object handle)
Sets the serialization handle |
protected byte[] |
stringToDigest(java.lang.String digest)
|
java.lang.String |
toString()
|
java.lang.Object |
writeReplace()
Serialize to the handle |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String LOGIN_NAME
protected int _principalCacheSize
protected LruCache<java.lang.String,com.caucho.server.security.AbstractAuthenticator.PrincipalEntry> _principalCache
protected java.lang.String _passwordDigestAlgorithm
protected java.lang.String _passwordDigestRealm
protected PasswordDigest _passwordDigest
| Constructor Detail |
|---|
public AbstractAuthenticator()
| Method Detail |
|---|
public int getPrincipalCacheSize()
public void setPrincipalCacheSize(int size)
public PasswordDigest getPasswordDigest()
public void setPasswordDigest(PasswordDigest digest)
public java.lang.String getPasswordDigestAlgorithm()
public void setPasswordDigestAlgorithm(java.lang.String digest)
public java.lang.String getPasswordDigestRealm()
public void setPasswordDigestRealm(java.lang.String realm)
public boolean getLogoutOnSessionTimeout()
public void setLogoutOnSessionTimeout(boolean logout)
public void addRoleMapping(java.security.Principal principal,
java.lang.String role)
public void init()
throws ServletException
init in interface ServletAuthenticatorServletException
public java.security.Principal login(HttpServletRequest request,
HttpServletResponse response,
ServletContext app,
java.lang.String user,
java.lang.String password)
throws ServletException
login in interface ServletAuthenticatorrequest - servlet requestresponse - servlet response, in case any cookie need sending.app - servlet applicationuser - the user name.password - the users input password.
ServletException
public java.lang.String getPasswordDigest(HttpServletRequest request,
HttpServletResponse response,
ServletContext app,
java.lang.String user,
java.lang.String password)
throws ServletException
ServletException
protected java.security.Principal loginImpl(HttpServletRequest request,
HttpServletResponse response,
ServletContext application,
java.lang.String user,
java.lang.String password)
throws ServletException
ServletException
public java.security.Principal loginDigest(HttpServletRequest request,
HttpServletResponse response,
ServletContext app,
java.lang.String user,
java.lang.String realm,
java.lang.String nonce,
java.lang.String uri,
java.lang.String qop,
java.lang.String nc,
java.lang.String cnonce,
byte[] clientDigest)
throws ServletException
The HTTP Digest authentication uses the following algorithm
to calculate the digest. The digest is then compared to
the client digest.
A1 = MD5(username + ':' + realm + ':' + password)
A2 = MD5(method + ':' + uri)
digest = MD5(A1 + ':' + nonce + A2)
loginDigest in interface ServletAuthenticatorrequest - the request trying to authenticate.response - the response for setting headers and cookies.app - the servlet contextuser - the usernamerealm - the authentication realmnonce - the nonce passed to the client during the challengeuri - te protected uriqop - nc - cnonce - the client nonceclientDigest - the client's calculation of the digest
ServletException
public java.security.Principal loginDigestImpl(HttpServletRequest request,
HttpServletResponse response,
ServletContext app,
java.lang.String user,
java.lang.String realm,
java.lang.String nonce,
java.lang.String uri,
java.lang.String qop,
java.lang.String nc,
java.lang.String cnonce,
byte[] clientDigest)
throws ServletException
A1 = MD5(username + ':' + realm + ':' + password)
A2 = MD5(method + ':' + uri)
digest = MD5(A1 + ':' + nonce + A2)
request - the request trying to authenticate.response - the response for setting headers and cookies.app - the servlet contextuser - the usernamerealm - the authentication realmnonce - the nonce passed to the client during the challengeuri - te protected uriqop - nc - cnonce - the client nonceclientDigest - the client's calculation of the digest
ServletExceptionprotected byte[] stringToDigest(java.lang.String digest)
protected byte[] getDigestSecret(HttpServletRequest request,
HttpServletResponse response,
ServletContext application,
java.lang.String username,
java.lang.String realm,
java.lang.String algorithm)
throws ServletException
ServletException
protected byte[] digest(java.lang.String value)
throws ServletException
ServletException
protected java.lang.String getDigestPassword(HttpServletRequest request,
HttpServletResponse response,
ServletContext application,
java.lang.String username,
java.lang.String realm)
throws ServletException
ServletException
public java.security.Principal getUserPrincipal(HttpServletRequest request,
HttpServletResponse response,
ServletContext application)
throws ServletException
getUserPrincipal in interface ServletAuthenticatorrequest - the servlet request.response - the response for setting headers and cookies.application - the servlet context
ServletException
protected java.security.Principal getUserPrincipalImpl(HttpServletRequest request,
ServletContext application)
throws ServletException
ServletException
public boolean isUserInRole(HttpServletRequest request,
HttpServletResponse response,
ServletContext application,
java.security.Principal user,
java.lang.String role)
throws ServletException
isUserInRole in interface ServletAuthenticatorrequest - the servlet requestuser - the user to testrole - the role to testapplication - the owning application
ServletException
public void logout(ServletContext application,
HttpSession timeoutSession,
java.lang.String sessionId,
java.security.Principal user)
throws ServletException
logout in interface ServletAuthenticatorapplication - the applicationtimeoutSession - the session timing out, null if not a timeout logoutuser - the logged in user
ServletException
public void logout(HttpServletRequest request,
HttpServletResponse response,
ServletContext application,
java.security.Principal user)
throws ServletException
request - the servlet request
ServletException
public void logout(ServletContext application,
java.lang.String sessionId,
java.security.Principal user)
throws ServletException
request - the servlet request
ServletExceptionpublic void setSerializationHandle(java.lang.Object handle)
setSerializationHandle in interface HandleAwarepublic java.lang.Object writeReplace()
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||