public class AbstractAuthenticator extends java.lang.Object implements Authenticator, HandleAware, java.io.Serializable
The AbstractAuthenticator provides a single-signon cache. Users logged into one web-app will share the same principal.
Modifier and Type | Field and Description |
---|---|
protected PasswordDigest |
_passwordDigest |
protected java.lang.String |
_passwordDigestAlgorithm |
protected java.lang.String |
_passwordDigestRealm |
static java.security.Principal |
NULL_USER |
Constructor and Description |
---|
AbstractAuthenticator() |
Modifier and Type | Method and Description |
---|---|
void |
addRoleMapping(java.security.Principal principal,
java.lang.String role)
Adds a role mapping.
|
protected java.security.Principal |
authenticate(java.security.Principal principal,
char[] password)
Password-based authenticator.
|
java.security.Principal |
authenticate(java.security.Principal user,
Credentials credentials,
java.lang.Object details)
Authenticator main call to login a user.
|
protected java.security.Principal |
authenticate(java.security.Principal principal,
DigestCredentials cred,
java.lang.Object details)
Validates the user when Resin's Digest authentication.
|
protected java.security.Principal |
authenticate(java.security.Principal principal,
HttpDigestCredentials cred,
java.lang.Object details)
Validates the user when HTTP Digest authentication.
|
protected java.security.Principal |
authenticate(java.security.Principal principal,
PasswordCredentials cred,
java.lang.Object details)
Main authenticator API.
|
protected byte[] |
digest(java.lang.String value) |
java.lang.String |
getAlgorithm(java.security.Principal user) |
protected char[] |
getDigest(java.security.Principal user,
java.lang.String algorithm,
char[] testPassword,
char[] systemDigest) |
protected byte[] |
getDigestSecret(java.security.Principal principal,
java.lang.String realm)
Returns the digest secret for Digest authentication.
|
protected byte[] |
getDigestSecret(java.security.Principal principal,
java.lang.String realm,
char[] userPassword) |
boolean |
getLogoutOnSessionTimeout()
Returns true if the user should be logged out on a session timeout.
|
PasswordDigest |
getPasswordDigest()
Returns the password digest
|
protected char[] |
getPasswordDigest(java.lang.String user,
char[] 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
|
protected PasswordUser |
getPasswordUser(java.security.Principal principal)
Returns the user based on a principal
|
protected PasswordUser |
getPasswordUser(java.lang.String userName)
Abstract method to return a user based on the name
|
SingleSignon |
getSingleSignon()
Returns the scoped single-signon
|
void |
init()
Initialize the authenticator with the application.
|
boolean |
isUserInRole(java.security.Principal user,
java.lang.String role)
Returns true if the user plays the named role.
|
void |
logout(java.security.Principal user)
Logs the user out from the session.
|
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 |
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
|
public static final java.security.Principal NULL_USER
protected java.lang.String _passwordDigestAlgorithm
protected java.lang.String _passwordDigestRealm
protected PasswordDigest _passwordDigest
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)
@PostConstruct public void init() throws ServletException
ServletException
public java.lang.String getAlgorithm(java.security.Principal user)
getAlgorithm
in interface Authenticator
public java.security.Principal authenticate(java.security.Principal user, Credentials credentials, java.lang.Object details)
authenticate
in interface Authenticator
user
- the Login's user, generally a BasicPrincipal just containing
the name, but may contain an X.509 certificatecredentials
- the login credentialsdetails
- extra information, e.g. HttpServletRequestpublic boolean isUserInRole(java.security.Principal user, java.lang.String role)
isUserInRole
in interface Authenticator
user
- the user to testrole
- the role to testpublic void logout(java.security.Principal user)
logout
in interface Authenticator
user
- the logged in userprotected java.security.Principal authenticate(java.security.Principal principal, PasswordCredentials cred, java.lang.Object details)
protected java.security.Principal authenticate(java.security.Principal principal, char[] password)
protected java.security.Principal authenticate(java.security.Principal principal, HttpDigestCredentials cred, java.lang.Object details)
A1 = MD5(username + ':' + realm + ':' + password)
A2 = MD5(method + ':' + uri)
digest = MD5(A1 + ':' + nonce + A2)
principal
- the user trying to authenticate.cred
- the digest credentialsprotected java.security.Principal authenticate(java.security.Principal principal, DigestCredentials cred, java.lang.Object details)
A1 = MD5(username + ':' + realm + ':' + password)
digest = MD5(A1 + ':' + nonce)
principal
- the user trying to authenticate.cred
- the digest credentialsprotected char[] getPasswordDigest(java.lang.String user, char[] password)
protected byte[] getDigestSecret(java.security.Principal principal, java.lang.String realm)
protected byte[] getDigestSecret(java.security.Principal principal, java.lang.String realm, char[] userPassword)
protected PasswordUser getPasswordUser(java.lang.String userName)
userName
- the string user nameprotected PasswordUser getPasswordUser(java.security.Principal principal)
public SingleSignon getSingleSignon()
protected byte[] stringToDigest(java.lang.String digest)
protected byte[] digest(java.lang.String value) throws ServletException
ServletException
protected char[] getDigest(java.security.Principal user, java.lang.String algorithm, char[] testPassword, char[] systemDigest)
public void setSerializationHandle(java.lang.Object handle)
setSerializationHandle
in interface HandleAware
public java.lang.Object writeReplace()
public java.lang.String toString()
toString
in class java.lang.Object