|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.security.auth.spi.AbstractServerLoginModule
public abstract class AbstractServerLoginModule
This class implements the common functionality required for a JAAS server side LoginModule and implements the JBossSX standard Subject usage pattern of storing identities and roles. Subclass this module to create your own custom LoginModule and override the login(), getRoleSets() and getIdentity() methods.
You may also wish to override
public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options)In which case the first line of your initialize() method should be:
super.initialize(subject, callbackHandler, sharedState, options);
You may also wish to override
public boolean login() throws LoginExceptionIn which case the last line of your login() method should be
return super.login();
Field Summary | |
---|---|
protected CallbackHandler |
callbackHandler
|
protected org.jboss.logging.Logger |
log
|
protected boolean |
loginOk
Flag indicating if the login phase succeeded. |
protected Map |
options
|
protected String |
principalClassName
An optional custom Principal class implementation |
protected Map |
sharedState
|
protected Subject |
subject
|
protected Principal |
unauthenticatedIdentity
the principal to use when a null username and password are seen |
protected boolean |
useFirstPass
Flag indicating if the shared credential should be used |
Constructor Summary | |
---|---|
AbstractServerLoginModule()
|
Method Summary | |
---|---|
boolean |
abort()
Method to abort the authentication process (phase 2). |
boolean |
commit()
Method to commit the authentication process (phase 2). |
protected Group |
createGroup(String name,
Set principals)
Find or create a Group with the given name. |
protected Principal |
createIdentity(String username)
Utility method to create a Principal for the given username. |
protected abstract Principal |
getIdentity()
Overriden by subclasses to return the Principal that corresponds to the user primary identity. |
protected abstract Group[] |
getRoleSets()
Overriden by subclasses to return the Groups that correspond to the to the role sets assigned to the user. |
protected Principal |
getUnauthenticatedIdentity()
|
protected boolean |
getUseFirstPass()
|
void |
initialize(Subject subject,
CallbackHandler callbackHandler,
Map sharedState,
Map options)
Initialize the login module. |
boolean |
login()
Looks for javax.security.auth.login.name and javax.security.auth.login.password values in the sharedState map if the useFirstPass option was true and returns true if they exist. |
boolean |
logout()
Remove the user identity and roles added to the Subject during commit. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Subject subject
protected CallbackHandler callbackHandler
protected Map sharedState
protected Map options
protected org.jboss.logging.Logger log
protected boolean useFirstPass
protected boolean loginOk
protected String principalClassName
protected Principal unauthenticatedIdentity
Constructor Detail |
---|
public AbstractServerLoginModule()
Method Detail |
---|
public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options)
option: password-stacking: If this is set to "useFirstPass", the login
identity will be taken from the javax.security.auth.login.name
value of the sharedState map, and the proof of identity from the
javax.security.auth.login.password
value of the sharedState
map.
option: principalClass: A Principal implementation that support a ctor
taking a String argument for the princpal name.
option: unauthenticatedIdentity: the name of the principal to asssign
and authenticate when a null username and password are seen.
initialize
in interface LoginModule
subject
- the Subject to update after a successful login.callbackHandler
- the CallbackHandler that will be used to obtain the
the user identity and credentials.sharedState
- a Map shared between all configured login module instancesoptions
- the parameters passed to the login module.public boolean login() throws LoginException
login
in interface LoginModule
LoginException
public boolean commit() throws LoginException
commit
in interface LoginModule
LoginException
Subject;
,
Group;
public boolean abort() throws LoginException
abort
in interface LoginModule
LoginException
public boolean logout() throws LoginException
logout
in interface LoginModule
LoginException
protected abstract Principal getIdentity()
protected abstract Group[] getRoleSets() throws LoginException
LoginException
protected boolean getUseFirstPass()
protected Principal getUnauthenticatedIdentity()
protected Group createGroup(String name, Set principals)
protected Principal createIdentity(String username) throws Exception
username
- the name of the principal
Exception
- thrown if the custom principal type cannot be created.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |