|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.n52.security.authentication.loginmodule.AbstractLoginModule
public abstract class AbstractLoginModule
Class AbstractLoginModule is a abstract base class for login modules.
It implements the methodsLoginModule.initialize(
javax.security.auth.Subject,javax.security.auth.callback.CallbackHandler,java.util.Map,java.util.Map)
LoginModule.commit()
LoginModule.abort()
LoginModule.logout()
initialize()
, clearAuthenticationState()
,
performLogin()
and prepareCommitState()
.
Within the initialize method the login module can check given options and the shared state for context information.
In the performLogin method the login module performs the login, which means that it checks the authentication
credentials.
The prepareCommitState method is invoked during the commit phase of the authentication. Therein a login module can
store all principals and credentials for the user in the local principal and credentail sets (
addPrincipal(java.security.Principal)
, (addPrivateCredential(Object)
and (
addPublicCredential(Object)
). These will automatically applied to the user and removed in the
logout()
and abort()
methods.
The clearAuthenticationState method is invoked to tell a login module to release any authentication information
obtained from the user.
This class implements Serializable to make it possible to store LoginContexts for a subject for a longer time. Not
all fields can be serialized e.g. the CallbackHandler is omitted, therewith it makes only sense to serialize
authenticated login contexts, e.g. for later logout in a web application. Successfull serialization requires also
serializable credentials and principals.
Field Summary | |
---|---|
protected javax.security.auth.callback.CallbackHandler |
m_callbackHandler
Field m_callbackHandler holds the CallbackHandler. |
protected boolean |
m_commitSucceeded
Field m_commitSucceeded is a flat wich indicates a successfull execution of the commit method. |
protected boolean |
m_loginSucceeded
Field m_loginSucceeded is a flag wich indicates a successfull execution of the login method. |
protected Options |
m_options
Field m_options holds the options of the login module. |
protected java.util.Set |
m_principals
Field m_principals contains the principals, which shall or were applied to the subject. |
protected java.util.Set |
m_privateCredentials
Field m_privateCredentials contains the private credentials, which are created by this login module and shall or were applied to the subject. |
protected java.util.Set |
m_publicCredentials
Field m_publicCredentials contains the public credentials, which are created by this login module and shall or were applied to the subject. |
protected SharedState |
m_sharedState
Field m_sharedState holds the shared state. |
protected javax.security.auth.Subject |
m_subject
Field m_subject holds the Subject. |
Constructor Summary | |
---|---|
AbstractLoginModule()
|
Method Summary | |
---|---|
boolean |
abort()
Method aborts the authentication process. |
protected void |
addPrincipal(java.security.Principal principal)
Method adds a principal to the local principal set. |
protected void |
addPrivateCredential(java.lang.Object credential)
Method adds a private credential to the local private credential set. |
protected void |
addPublicCredential(java.lang.Object credential)
Method adds a public credential to the local public credential set. |
protected abstract void |
clearAuthenticationState()
Method cleanAuthenticationState is a template method used to invoke a cleanup of any authentication information provided by the user e.g. the user name and password used to login the user. |
protected boolean |
clearInternalState()
Method clearInternalState clears all internal principals and credentials and sets the state of loginSucceeded and commitSucceeded back to false and clears all references to external resouces (e.g. |
boolean |
commit()
Method commit checks if the login succeeded and if true it calls commitState() to apply all principals
and credentials to the subject. |
protected boolean |
commitState()
Method commitState applies all principals, public and private credentials created during the login or the prepareCommitState method to the subject and sets the internal commitSucceded state to true. |
protected boolean |
destroy(java.util.Set destroyables)
Method destroy checks the set for instances of Destroyable and destroys them. |
protected javax.security.auth.callback.CallbackHandler |
getCallbackHandler()
Method gets the callbackHandler. |
protected abstract java.lang.String |
getDescription()
Method gets the description of this LoginModule. |
protected Options |
getOptions()
Method gets the options of this AbstractLoginModule object. |
protected java.util.Set |
getPrincipals()
Method gets the principals created during the login method. |
protected java.util.Set |
getPrivateCredentials()
Method gets the privateCredentials created during the login method. |
protected java.util.Set |
getPublicCredentials()
Method gets the publicCredentials created during the login method. |
protected SharedState |
getSharedState()
Method gets the sharedState of this login context. |
protected javax.security.auth.Subject |
getSubject()
Method gets the subject of this login context. |
protected void |
handleCallbacks(javax.security.auth.callback.Callback[] callbacks)
Method handleCallbacks sends the given callback array to the callback handler. |
protected abstract void |
initialize()
Method initialize replaces the LoginModule.initialize(
javax.security.auth.Subject,javax.security.auth.callback.CallbackHandler,java.util.Map,java.util.Map)
. |
void |
initialize(javax.security.auth.Subject subject,
javax.security.auth.callback.CallbackHandler callbackHandler,
java.util.Map sharedState,
java.util.Map options)
Method initialize the login module. |
protected boolean |
isCallbackHandlerSet()
Method gets the callbackHandlerSet of this AbstractLoginModule object. |
protected boolean |
isCommitSucceeded()
Method gets the commitSucceeded flag. |
protected boolean |
isLoginSucceeded()
Method gets the loginSucceeded flag. |
boolean |
login()
Method checks the some default settings before it delegates to the performLogin method. |
boolean |
logout()
Method logout releases all state information applied during a commit from the subject. |
protected abstract boolean |
performLogin()
Method performs the real login, this is called by the pre implented login() method. |
protected abstract void |
prepareCommitState()
Method prepareCommitState is a template method used to let a sub class prepare all principals and credentials, which then will be applied to the subject. |
protected void |
setCommitSucceeded(boolean commitSucceeded)
Method sets the commit succeeded state of the login module. |
protected void |
setLoginSucceeded(boolean loginSucceeded)
Method sets the login succeeded state of the login module. |
protected void |
showModuleBanner()
Method showModuleBanner sends a description of the login module to the callback handler. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected javax.security.auth.Subject m_subject
getSubject()
protected transient javax.security.auth.callback.CallbackHandler m_callbackHandler
getCallbackHandler()
,
isCallbackHandlerSet()
protected SharedState m_sharedState
getSharedState()
protected Options m_options
getOptions()
protected java.util.Set m_principals
protected java.util.Set m_publicCredentials
protected java.util.Set m_privateCredentials
protected boolean m_loginSucceeded
protected boolean m_commitSucceeded
Constructor Detail |
---|
public AbstractLoginModule()
Method Detail |
---|
protected javax.security.auth.callback.CallbackHandler getCallbackHandler()
protected Options getOptions()
protected java.util.Set getPrincipals()
Principal
classes.protected java.util.Set getPrivateCredentials()
protected java.util.Set getPublicCredentials()
protected SharedState getSharedState()
protected javax.security.auth.Subject getSubject()
protected boolean isCommitSucceeded()
protected void setCommitSucceeded(boolean commitSucceeded)
commitSucceeded
- (true|false)protected boolean isLoginSucceeded()
protected void setLoginSucceeded(boolean loginSucceeded)
loginSucceeded
- (true|false).public boolean abort() throws javax.security.auth.login.LoginException
abort
in interface javax.security.auth.spi.LoginModule
javax.security.auth.login.LoginException
- if error occurs.public boolean commit() throws javax.security.auth.login.LoginException
commitState()
to apply all principals
and credentials to the subject.
commit
in interface javax.security.auth.spi.LoginModule
javax.security.auth.login.LoginException
- if error occurs.public boolean logout() throws javax.security.auth.login.LoginException
logout
in interface javax.security.auth.spi.LoginModule
javax.security.auth.login.LoginException
- if error occurs.public boolean login() throws javax.security.auth.login.LoginException
login
in interface javax.security.auth.spi.LoginModule
javax.security.auth.login.LoginException
- if error occurs.protected abstract boolean performLogin() throws javax.security.auth.login.LoginException
javax.security.auth.login.LoginException
- if error occurs.public void initialize(javax.security.auth.Subject subject, javax.security.auth.callback.CallbackHandler callbackHandler, java.util.Map sharedState, java.util.Map options)
SharedState
and Options
.
initialize
in interface javax.security.auth.spi.LoginModule
subject
- the subject.callbackHandler
- the callbackHandler can be null.sharedState
- the sharedState map.options
- the options map.LoginModule.initialize(
javax.security.auth.Subject,javax.security.auth.callback.CallbackHandler,java.util.Map,java.util.Map)
,
Description of the initialize method in the LoginModule Developer's Guide protected void addPrincipal(java.security.Principal principal)
principal
- a principal created during login.protected void addPrivateCredential(java.lang.Object credential)
credential
- a private credential created during login.protected void addPublicCredential(java.lang.Object credential)
credential
- a public credential created during login.protected boolean clearInternalState() throws javax.security.auth.login.LoginException
clearAuthenticationState()
method to ensure that no user credentials are further stored.
javax.security.auth.login.LoginException
- if error occurs.protected abstract void clearAuthenticationState() throws javax.security.auth.login.LoginException
javax.security.auth.login.LoginException
- if an error occurs.protected boolean commitState() throws javax.security.auth.login.LoginException
clearAuthenticationState()
.
javax.security.auth.login.LoginException
- if commit fails e.g. because the subject is readonly.login()
,
addPrincipal(java.security.Principal)
,
addPrivateCredential(Object)
,
addPublicCredential(Object)
protected abstract void prepareCommitState() throws javax.security.auth.login.LoginException
javax.security.auth.login.LoginException
- if error occurs.protected boolean destroy(java.util.Set destroyables)
Destroyable
and destroys them.
The method only returns true if all instances within the set are Destroyables and the destroy method succeeded on
all.
destroyables
- the destroyables.
protected abstract void initialize()
LoginModule.initialize(
javax.security.auth.Subject,javax.security.auth.callback.CallbackHandler,java.util.Map,java.util.Map)
.
All parameters of the original initialize method can be retrieved by getter methods.
A subclasses shall check the options and initializes them self.
LoginModule.initialize(
javax.security.auth.Subject,javax.security.auth.callback.CallbackHandler,java.util.Map,java.util.Map)
,
Description of the initialize method in the LoginModule Developer's Guide protected boolean isCallbackHandlerSet()
protected void showModuleBanner() throws javax.security.auth.login.LoginException
Options.isModuleBanner()
is set.
javax.security.auth.login.LoginException
- if a error occurs within the callback handler during this operation.Options.OPTION_MODULEBANNER
protected abstract java.lang.String getDescription()
TextOutputCallback
on the callback handler.
Options.OPTION_MODULEBANNER
,
showModuleBanner()
protected void handleCallbacks(javax.security.auth.callback.Callback[] callbacks) throws javax.security.auth.login.LoginException
callbacks
- the callbacks to execute.
javax.security.auth.login.LoginException
- if error occurs in the callback handler.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |