|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.jackrabbit.core.security.authentication.AbstractLoginModule
public abstract class AbstractLoginModule
AbstractLoginModule provides the means for the common
authentication tasks within the Repository.
PrincipalProvider configured for this LoginModule
Jackrabbit distinguishes between Login and Impersonation dispatching the
the correspoding Repository/Session methods to
authenticate(java.security.Principal, javax.jcr.Credentials) and
impersonate(java.security.Principal, javax.jcr.Credentials), respectively.
LoginModule| Field Summary | |
|---|---|
protected java.lang.String |
adminId
|
protected java.lang.String |
anonymousId
|
protected javax.jcr.SimpleCredentials |
credentials
|
protected java.security.Principal |
principal
|
protected PrincipalProvider |
principalProvider
|
protected javax.security.auth.Subject |
subject
|
| Constructor Summary | |
|---|---|
AbstractLoginModule()
|
|
| Method Summary | |
|---|---|
boolean |
abort()
Method to abort the authentication process (phase 2). |
protected boolean |
authenticate(java.security.Principal principal,
javax.jcr.Credentials credentials)
|
boolean |
commit()
Method to commit the authentication process (phase 2). |
protected abstract void |
doInit(javax.security.auth.callback.CallbackHandler callbackHandler,
javax.jcr.Session session,
java.util.Map options)
Implementations may set-up their own state. |
java.lang.String |
getAdminId()
Returns the admin user id. |
java.lang.String |
getAnonymousId()
Returns the anonymous user id. |
protected abstract Authentication |
getAuthentication(java.security.Principal principal,
javax.jcr.Credentials creds)
|
protected javax.jcr.Credentials |
getCredentials()
Method tries to resolve the Credentials used for login. |
protected javax.security.auth.Subject |
getImpersonatorSubject(javax.jcr.Credentials credentials)
Method tries to acquire an Impersonator in the follwing order: Try to access it from the Credentials via SimpleCredentials.getAttribute(String)
Ask CallbackHandler for Impersonator with use of ImpersonationCallback.
|
protected abstract java.security.Principal |
getPrincipal(javax.jcr.Credentials credentials)
Authentication process associates a Principal to Credentials This method resolves the Principal for the given Credentials. |
java.lang.String |
getPrincipalProvider()
Returns the configured name of the principal provider class. |
protected java.util.Set |
getPrincipals()
|
protected java.lang.String |
getUserID(javax.jcr.Credentials credentials)
Method supports tries to acquire a UserID in the follwing order: If passed credentials are GuestCredentials the anonymous user id
is returned.
Try to access it from the Credentials via SimpleCredentials.getUserID()
Ask CallbackHandler for User-ID with use of NameCallback.
Test if the 'sharedState' contains a login name.
Fallback: return the anonymous UserID.
|
protected abstract boolean |
impersonate(java.security.Principal principal,
javax.jcr.Credentials credentials)
Handles the impersonation of given Credentials. Current implementation takes User for the given Principal and
delegates the check to Impersonation.allows(javax.security.auth.Subject) } |
void |
initialize(javax.security.auth.Subject subject,
javax.security.auth.callback.CallbackHandler callbackHandler,
java.util.Map sharedState,
java.util.Map options)
Initialize this LoginModule. This abstract implementation, initalizes the following fields for later use: PrincipalManager for group-membership resoultion
PrincipalProvider for user-Principal resolution.
LoginModuleConfig.PARAM_ADMIN_ID option is evaluated
LoginModuleConfig.PARAM_ANONYMOUS_ID option is evaluated
Implementations are called via
doInit(CallbackHandler, Session, Map) to implement
additional initalization |
protected boolean |
isAnonymous(javax.jcr.Credentials credentials)
Indicate if the given Credentials are considered to be anonymous. |
protected boolean |
isImpersonation(javax.jcr.Credentials credentials)
Test if the current request is an Impersonation attempt. |
protected boolean |
isInitialized()
Returns true if this module has been successfully initialized. |
boolean |
login()
Method to authenticate a Subject (phase 1).
The login is devided into 3 Phases:
1) User-ID resolutionIn a first step it is tried to resolve a User-ID for further validation. |
boolean |
logout()
Method which logs out a Subject. |
void |
setAdminId(java.lang.String adminId)
Sets the administrator's user id. |
void |
setAnonymousId(java.lang.String anonymousId)
Sets the anonymous user id. |
void |
setPrincipalProvider(java.lang.String principalProvider)
Sets the configured name of the principal provider class |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.String adminId
protected java.lang.String anonymousId
protected java.security.Principal principal
protected javax.jcr.SimpleCredentials credentials
protected javax.security.auth.Subject subject
protected PrincipalProvider principalProvider
| Constructor Detail |
|---|
public AbstractLoginModule()
| Method Detail |
|---|
public void initialize(javax.security.auth.Subject subject,
javax.security.auth.callback.CallbackHandler callbackHandler,
java.util.Map sharedState,
java.util.Map options)
PrincipalManager for group-membership resoultionPrincipalProvider for user-Principal resolution.LoginModuleConfig.PARAM_ADMIN_ID option is evaluatedLoginModuleConfig.PARAM_ANONYMOUS_ID option is evaluateddoInit(CallbackHandler, Session, Map) to implement
additional initalization
initialize in interface javax.security.auth.spi.LoginModulesubject - the Subject to be authenticated. callbackHandler - a CallbackHandler for communicating
with the end user (prompting for usernames and
passwords, for example). sharedState - state shared with other configured
LoginModules.options - options specified in the login Configuration
for this particular LoginModule.LoginModule.initialize(Subject, CallbackHandler, Map, Map),
doInit(CallbackHandler, Session, Map),
isInitialized()
protected abstract void doInit(javax.security.auth.callback.CallbackHandler callbackHandler,
javax.jcr.Session session,
java.util.Map options)
throws javax.security.auth.login.LoginException
callbackHandler - as passed by LoginContextsession - to security-workspace of Jackrabbitoptions - options from Logini config
javax.security.auth.login.LoginException - in case initializeaiton failesprotected boolean isInitialized()
true if this module has been successfully initialized.
true if this module has been successfully initialized.LoginModule.initialize(Subject, CallbackHandler, Map, Map)
public boolean login()
throws javax.security.auth.login.LoginException
Subject (phase 1).
The login is devided into 3 Phases:
1) User-ID resolutionCredentials
interface, credentials are accessed in this phase.PrincipalProvider has a principal
for the given ID and the principal can be found via
PrincipalProvider.findPrincipals(String).principal_provider.class.
If the option is missing, the system default prinvipal provider will
be used.
3) VerficationSession.impersonate(Credentials) or of a login to the Repository (Repository.login(Credentials)). The concrete implementation
of the LoginModule is responsible for both impersonation and login:
Under the following conditions, the login process is aborted and the
module is marked to be ignored:
login in interface javax.security.auth.spi.LoginModuleLoginModule should be ignored.
javax.security.auth.login.LoginException - if the authentication failsLoginModule.login(),
getCredentials(),
getUserID(Credentials),
getImpersonatorSubject(Credentials)
public boolean commit()
throws javax.security.auth.login.LoginException
login method),
then this method associates relevant Principals and Credentials with the
Subject located in the LoginModule. If this
LoginModule's own authentication attempted failed, then this method
removes/destroys any state that was originally saved.
The login is considers as succeeded if the credentials field is set. If
there is no principal set the login is considered as ignored.
The implementation stores the principal associated to the UserID and all
the Groups it is member of. PrincipalManager.getGroupMembership(Principal)
An instance of (#link SimpleCredentials} containing only the UserID used
to login is set to the Subject's public Credentials.
commit in interface javax.security.auth.spi.LoginModuleLoginModule should be ignored.
javax.security.auth.login.LoginException - if the commit failsLoginModule.commit(),
login()
public boolean abort()
throws javax.security.auth.login.LoginException
This method is called if the LoginContext's overall authentication failed. (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules did not succeed).
If this LoginModule's own authentication attempt succeeded (checked
by retrieving the private state saved by the login method),
then this method cleans up any state that was originally saved.
abort in interface javax.security.auth.spi.LoginModuleLoginModule should be ignored.
javax.security.auth.login.LoginException - if the abort fails
public boolean logout()
throws javax.security.auth.login.LoginException
Subject.
An implementation of this method might remove/destroy a Subject's Principals and Credentials.
logout in interface javax.security.auth.spi.LoginModuleLoginModule should be ignored.
javax.security.auth.login.LoginException - if the logout fails
protected boolean authenticate(java.security.Principal principal,
javax.jcr.Credentials credentials)
throws javax.jcr.RepositoryException,
javax.security.auth.login.FailedLoginException
principal - credentials -
true if Credentails authenticate,
false if no Authentication can handle
the given Credentials
javax.security.auth.login.FailedLoginException - if the authentication failed.
javax.jcr.RepositoryExceptiongetAuthentication(java.security.Principal, javax.jcr.Credentials),
authenticate(java.security.Principal, javax.jcr.Credentials)protected boolean isImpersonation(javax.jcr.Credentials credentials)
true if an
subject for the
impersonation can be retrieved.
credentials - potentially containing impersonation data
getImpersonatorSubject(Credentials)
protected abstract boolean impersonate(java.security.Principal principal,
javax.jcr.Credentials credentials)
throws javax.jcr.RepositoryException,
javax.security.auth.login.LoginException
User for the given Principal and
delegates the check to Impersonation.allows(javax.security.auth.Subject) }
principal - credentials -
javax.jcr.RepositoryException
javax.security.auth.login.FailedLoginException - if credentials don't allow to impersonate to principal
javax.security.auth.login.LoginException
protected abstract Authentication getAuthentication(java.security.Principal principal,
javax.jcr.Credentials creds)
throws javax.jcr.RepositoryException
principal - creds -
javax.jcr.RepositoryExceptionprotected javax.security.auth.Subject getImpersonatorSubject(javax.jcr.Credentials credentials)
Credentials via SimpleCredentials.getAttribute(String)ImpersonationCallback.
credentials - which, may contain an impersonation Subject
login(),
impersonate(java.security.Principal, javax.jcr.Credentials)protected javax.jcr.Credentials getCredentials()
Credentials used for login. It takes
authentication-extension of an already authenticated Subject into
accout.
Therefore the credentials are searchred as follows:
CredentialsCallback. Expects CredentialsCallback.getCredentials()
to return an instance of Credentials.SimpleCredentials see
Subject.getPublicCredentials(Class), thus enabling to
preauthenticate the Subject.
login()protected java.lang.String getUserID(javax.jcr.Credentials credentials)
GuestCredentials the anonymous user id
is returned.Credentials via SimpleCredentials.getUserID()NameCallback.
credentials - which, may contain a User-ID
login()protected boolean isAnonymous(javax.jcr.Credentials credentials)
credentials -
protected abstract java.security.Principal getPrincipal(javax.jcr.Credentials credentials)
credentials -
null.protected java.util.Set getPrincipals()
public java.lang.String getAdminId()
public void setAdminId(java.lang.String adminId)
adminId - the administrator's user id.public java.lang.String getAnonymousId()
public void setAnonymousId(java.lang.String anonymousId)
anonymousId - anonymous user idpublic java.lang.String getPrincipalProvider()
public void setPrincipalProvider(java.lang.String principalProvider)
principalProvider - Name of the principal provider class.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||