public abstract class AbstractLoginModule
extends java.lang.Object
implements javax.security.auth.spi.LoginModule
LoginModule
that implements
base functionality. The methods login()
and commit()
must
be implemented by subclasses. The default implementations of
initialize(Subject, CallbackHandler, Map, Map)
, abort()
and
logout()
should be sufficient for most purposes.Modifier and Type | Field and Description |
---|---|
protected javax.security.auth.callback.CallbackHandler |
m_handler |
protected java.util.Map<java.lang.String,?> |
m_options |
protected java.util.Collection<java.security.Principal> |
m_previousWikiPrincipals
Deprecated.
|
protected java.util.Collection<java.security.Principal> |
m_principals
Implementing classes should add Principals to this collection; these
will be added to the principal set when the overall login succeeds.
|
protected java.util.Collection<java.security.Principal> |
m_principalsToOverwrite
Deprecated.
|
protected java.util.Collection<java.security.Principal> |
m_principalsToRemove
Deprecated.
|
protected java.util.Map<java.lang.String,?> |
m_state |
protected javax.security.auth.Subject |
m_subject |
protected static java.lang.String |
NULL |
Constructor and Description |
---|
AbstractLoginModule() |
Modifier and Type | Method and Description |
---|---|
boolean |
abort()
Aborts the login; called if the LoginContext's overall authentication
failed.
|
boolean |
commit()
Commits the login.
|
void |
initialize(javax.security.auth.Subject subject,
javax.security.auth.callback.CallbackHandler callbackHandler,
java.util.Map<java.lang.String,?> sharedState,
java.util.Map<java.lang.String,?> options)
Initializes the LoginModule with a given
Subject ,
callback handler, options and shared state. |
abstract boolean |
login()
Logs in the user by calling back to the registered CallbackHandler with a
series of callbacks.
|
boolean |
logout()
Logs the user out.
|
protected javax.security.auth.callback.CallbackHandler m_handler
protected java.util.Map<java.lang.String,?> m_options
protected java.util.Collection<java.security.Principal> m_previousWikiPrincipals
protected java.util.Collection<java.security.Principal> m_principals
commit()
phase of login.protected java.util.Collection<java.security.Principal> m_principalsToRemove
Role
.protected java.util.Collection<java.security.Principal> m_principalsToOverwrite
Role
. For example,
CookieAssertionLoginModule
adds
Role.ANONYMOUS
to its
m_principalsToOverwrite
collection because when it
succeeds, its own Role.AUTHENTICATED
should over-write Role.ANONYMOUS
.protected java.util.Map<java.lang.String,?> m_state
protected javax.security.auth.Subject m_subject
protected static final java.lang.String NULL
public final boolean abort() throws javax.security.auth.login.LoginException
m_principalsToRemove
.
It always returns true
.abort
in interface javax.security.auth.spi.LoginModule
javax.security.auth.login.LoginException
- if the abort itself failsLoginModule.abort()
public final boolean commit()
m_principals
member variable is consulted to determine
whether to add the principals. If its size is 0 (because the login
failed), the login is considered to have failed; in this case,
all principals in m_principalsToRemove
are removed
from the Subject's set. Otherwise, the principals added to
m_principals
in the login()
method are added to
the Subject's set.commit
in interface javax.security.auth.spi.LoginModule
true
if the commit succeeded, or
false
if the previous call to login()
failedLoginModule.commit()
public final void initialize(javax.security.auth.Subject subject, javax.security.auth.callback.CallbackHandler callbackHandler, java.util.Map<java.lang.String,?> sharedState, java.util.Map<java.lang.String,?> options)
Subject
,
callback handler, options and shared state. In particular, the member
variable m_principals
is initialized as a blank Set.initialize
in interface javax.security.auth.spi.LoginModule
subject
- callbackHandler
- sharedState
- options
- LoginModule.initialize(javax.security.auth.Subject,
javax.security.auth.callback.CallbackHandler, java.util.Map,
java.util.Map)
public abstract boolean login() throws javax.security.auth.login.LoginException
true
login
in interface javax.security.auth.spi.LoginModule
true
if the commit succeeded, or
false
if this LoginModule should be ignored.javax.security.auth.login.LoginException
- if the authentication failsLoginModule.login()
public final boolean logout() throws javax.security.auth.login.LoginException
m_principalsToRemove
from the Subject's principal set.logout
in interface javax.security.auth.spi.LoginModule
true
if the commit succeeded, or
false
if this LoginModule should be ignoredjavax.security.auth.login.LoginException
- if the logout itself failsLoginModule.logout()
stSoftware Copyright © 2001-2014 stSoftware All Rights Reserved.