|
JSecurity | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jsecurity.authc.AbstractAuthenticator
public abstract class AbstractAuthenticator
Superclass for almost all Authenticator implementations that performs the common work around authentication
attempts.
This class delegates the actual authentication attempt to subclasses but supports notification for
successful and failed logins as well as logouts. Notification is sent to one or more registered
AuthenticationListeners to allow for custom processing logic
when these conditions occur.
In most cases, the only thing a subclass needs to do (via its doAuthenticate(org.jsecurity.authc.AuthenticationToken) implementation)
is perform the actual principal/credential verification process for the submitted AuthenticationToken.
| Constructor Summary | |
|---|---|
AbstractAuthenticator()
|
|
| Method Summary | |
|---|---|
void |
add(AuthenticationListener listener)
|
AuthenticationInfo |
authenticate(AuthenticationToken token)
Implementation of the Authenticator interface that functions in the following manner:
Calls template doAuthenticate method for subclass execution of the actual
authentication behavior. |
protected abstract AuthenticationInfo |
doAuthenticate(AuthenticationToken token)
Template design pattern hook for subclasses to implement specific authentication behavior. |
protected void |
notifyFailure(AuthenticationToken token,
AuthenticationException ae)
|
protected void |
notifyLogout(PrincipalCollection principals)
|
protected void |
notifySuccess(AuthenticationToken token,
AuthenticationInfo info)
|
void |
onLogout(PrincipalCollection principals)
Callback triggered when a Subject logs out of the system. |
boolean |
remove(AuthenticationListener listener)
|
void |
setAuthenticationListeners(Collection<AuthenticationListener> listeners)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractAuthenticator()
| Method Detail |
|---|
public void setAuthenticationListeners(Collection<AuthenticationListener> listeners)
setAuthenticationListeners in interface AuthenticationListenerRegistrarpublic void add(AuthenticationListener listener)
add in interface AuthenticationListenerRegistrarpublic boolean remove(AuthenticationListener listener)
remove in interface AuthenticationListenerRegistrar
protected void notifySuccess(AuthenticationToken token,
AuthenticationInfo info)
protected void notifyFailure(AuthenticationToken token,
AuthenticationException ae)
protected void notifyLogout(PrincipalCollection principals)
public void onLogout(PrincipalCollection principals)
LogoutAwareSubject logs out of the system.
onLogout in interface LogoutAwareprincipals - the identifying principals of the Subject logging out.
public final AuthenticationInfo authenticate(AuthenticationToken token)
throws AuthenticationException
Authenticator interface that functions in the following manner:
doAuthenticate method for subclass execution of the actual
authentication behavior.AuthenticationListeners of the exception and then propogate the exception
for the caller to handle.AuthenticationListeners of the successful attempt.
authenticate in interface Authenticatortoken - the submitted token representing the subject's (user's) login principals and credentials.
AuthenticationException - if there is any problem during the authentication process - see the
interface's JavaDoc for a more detailed explanation.ExpiredCredentialsException,
IncorrectCredentialsException,
ExcessiveAttemptsException,
LockedAccountException,
ConcurrentAccessException,
UnknownAccountException
protected abstract AuthenticationInfo doAuthenticate(AuthenticationToken token)
throws AuthenticationException
Common behavior for most authentication attempts is encapsulated in the
authenticate(org.jsecurity.authc.AuthenticationToken) method and that method invokes this one for custom behavior.
N.B. Subclasses should throw some kind of AuthenticationException if there is a problem during authentication instead of returning null. A null return value indicates a configuration or programming error, since AuthenticationExceptions should indicate any expected problem (such as an unknown account or username, or invalid password, etc).
token - the authentication token encapsulating the user's login information.
AuthenticationException - if there is a problem logging in the user.
|
JSecurity | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||