public abstract class AbstractLoginModule extends Object implements 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 CallbackHandler |
m_handler |
protected Map<String,?> |
m_options |
protected Collection<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 Map<String,?> |
m_state |
protected Subject |
m_subject |
protected static 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(Subject subject,
CallbackHandler callbackHandler,
Map<String,?> sharedState,
Map<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 CallbackHandler m_handler
protected Collection<Principal> m_principals
commit()
phase of login.protected static final String NULL
public AbstractLoginModule()
public final boolean abort()
m_principals
.
It always returns true
.abort
in interface LoginModule
LoginModule.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_principals
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 LoginModule
true
if the commit succeeded, or
false
if the previous call to login()
failedLoginModule.commit()
public final void initialize(Subject subject, CallbackHandler callbackHandler, Map<String,?> sharedState, Map<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 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 LoginException
true
login
in interface LoginModule
true
if the commit succeeded, or
false
if this LoginModule should be ignored.LoginException
- if the authentication failsLoginModule.login()
public final boolean logout()
m_principals
from the Subject's principal set.logout
in interface LoginModule
true
if the commit succeeded, or
false
if this LoginModule should be ignoredLoginModule.logout()
Copyright © 2001-2019 The Apache Software Foundation. All rights reserved.