org.apache.jackrabbit.core.security.authentication
Class DefaultLoginModule

java.lang.Object
  extended by org.apache.jackrabbit.core.security.authentication.AbstractLoginModule
      extended by org.apache.jackrabbit.core.security.authentication.DefaultLoginModule
All Implemented Interfaces:
LoginModule

public class DefaultLoginModule
extends AbstractLoginModule

The DefaultLoginModule authenticates Credentials related to a User of the Repository
In any other case it is marked to be ignored.

This Module can deal only with SimpleCredentials since it uses by default the SimpleCredentialsAuthentication. Impersonation is delegated to the User's Impersonation object

See Also:
AbstractLoginModule

Field Summary
protected  User user
           
 
Fields inherited from class org.apache.jackrabbit.core.security.authentication.AbstractLoginModule
adminId, anonymousId, callbackHandler, credentials, principal, principalProvider, sharedState, subject
 
Constructor Summary
DefaultLoginModule()
           
 
Method Summary
protected  void doInit(CallbackHandler callbackHandler, Session session, Map options)
          Retrieves the user manager from the specified session.
protected  Authentication getAuthentication(Principal principal, Credentials creds)
          Retrieve the Authentication.
protected  Principal getPrincipal(Credentials credentials)
          Resolves the userID from the given credentials and obtains the principal from the User object associated with the given userID.
protected  boolean impersonate(Principal principal, Credentials credentials)
          Handles the impersonation of given Credentials.
 
Methods inherited from class org.apache.jackrabbit.core.security.authentication.AbstractLoginModule
abort, authenticate, commit, getAdminId, getAnonymousId, getCredentials, getImpersonatorSubject, getPreAuthAttributeName, getPrincipalProvider, getPrincipals, getUserID, initialize, isAnonymous, isImpersonation, isInitialized, isPreAuthenticated, login, logout, setAdminId, setAnonymousId, setPrincipalProvider, supportsCredentials
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

user

protected User user
Constructor Detail

DefaultLoginModule

public DefaultLoginModule()
Method Detail

doInit

protected void doInit(CallbackHandler callbackHandler,
                      Session session,
                      Map options)
               throws LoginException
Retrieves the user manager from the specified session. If this fails this login modules initialization must fail.

Specified by:
doInit in class AbstractLoginModule
Parameters:
callbackHandler - as passed by LoginContext
session - to security-workspace of Jackrabbit
options - options from Logini config
Throws:
LoginException - in case initialization failes
See Also:
AbstractLoginModule.doInit(CallbackHandler, Session, Map)

getPrincipal

protected Principal getPrincipal(Credentials credentials)
Resolves the userID from the given credentials and obtains the principal from the User object associated with the given userID. If the the userID cannot be resolved to a User or if obtaining the principal fail, null is returned.

Specified by:
getPrincipal in class AbstractLoginModule
Parameters:
credentials - Credentials to retrieve the principal for.
Returns:
a user principal or null.
See Also:
AbstractLoginModule.getPrincipal(Credentials)

getAuthentication

protected Authentication getAuthentication(Principal principal,
                                           Credentials creds)
                                    throws RepositoryException
Description copied from class: AbstractLoginModule
Retrieve the Authentication.

Specified by:
getAuthentication in class AbstractLoginModule
Parameters:
principal - A principal.
creds - The Credentials used for the login.
Returns:
Authentication object for the given principal / credentials.
Throws:
RepositoryException - If an error occurs.
See Also:
AbstractLoginModule.getAuthentication(Principal, Credentials)

impersonate

protected boolean impersonate(Principal principal,
                              Credentials credentials)
                       throws RepositoryException,
                              FailedLoginException
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)

Specified by:
impersonate in class AbstractLoginModule
Parameters:
principal - Principal to impersonate.
credentials - Credentials used to create the impersonation subject.
Returns:
false, if there is no User to impersonate, true if impersonation is allowed
Throws:
RepositoryException
FailedLoginException - if credentials don't allow to impersonate to principal
See Also:
AbstractLoginModule.impersonate(Principal, Credentials)


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.