Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.acegisecurity.providers
Class ProviderManager  view ProviderManager download ProviderManager.java

java.lang.Object
  extended byorg.acegisecurity.AbstractAuthenticationManager
      extended byorg.acegisecurity.providers.ProviderManager
All Implemented Interfaces:
org.springframework.context.ApplicationEventPublisherAware, org.acegisecurity.AuthenticationManager, org.springframework.beans.factory.InitializingBean, org.springframework.context.MessageSourceAware

public class ProviderManager
extends org.acegisecurity.AbstractAuthenticationManager
implements org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationEventPublisherAware, org.springframework.context.MessageSourceAware

Iterates an org.acegisecurity.Authentication request through a list of AuthenticationProviders. Can optionally be configured with a ConcurrentSessionController to limit the number of sessions a user can have.

AuthenticationProviders are tried in order until one provides a non-null response. A non-null response indicates the provider had authority to decide on the authentication request and no further providers are tried. If an AuthenticationException is thrown by a provider, it is retained until subsequent providers are tried. If a subsequent provider successfully authenticates the request, the earlier authentication exception is disregarded and the successful authentication will be used. If no subsequent provider provides a non-null response, or a new AuthenticationException, the last AuthenticationException received will be used. If no provider returns a non-null response, or indicates it can even process an Authentication, the ProviderManager will throw a ProviderNotFoundException.

If a valid Authentication is returned by an AuthenticationProvider, the ProviderManager will publish an org.acegisecurity.event.authentication.AuthenticationSuccessEvent. If an AuthenticationException is detected, the final AuthenticationException thrown will be used to publish an appropriate failure event. By default ProviderManager maps common exceptions to events, but this can be fine-tuned by providing a new exceptionMappingsjava.util.Properties object. In the properties object, each of the keys represent the fully qualified classname of the exception, and each of the values represent the name of an event class which subclasses org.acegisecurity.event.authentication.AbstractAuthenticationFailureEvent and provides its constructor.


Field Summary
private  org.springframework.context.ApplicationEventPublisher applicationEventPublisher
           
private  java.util.Properties exceptionMappings
           
private static org.apache.commons.logging.Log logger
           
protected  org.springframework.context.support.MessageSourceAccessor messages
           
private  java.util.List providers
           
private  ConcurrentSessionController sessionController
           
 
Constructor Summary
ProviderManager()
           
 
Method Summary
 void afterPropertiesSet()
          Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
private  void checkIfValidList(java.util.List listToCheck)
           
protected  void doAddExtraDefaultExceptionMappings(java.util.Properties exceptionMappings)
          Provided so subclasses can add extra exception mappings during startup if no exception mappings are injected by the IoC container.
 org.acegisecurity.Authentication doAuthentication(org.acegisecurity.Authentication authentication)
          Attempts to authenticate the passed org.acegisecurity.Authentication object.
 java.util.List getProviders()
           
 ConcurrentSessionController getSessionController()
          The configured ConcurrentSessionController is returned or the NullConcurrentSessionController if a specific one has not been set.
 void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
          Set the ApplicationEventPublisher that this object runs in.
 void setMessageSource(org.springframework.context.MessageSource messageSource)
          Set the MessageSource that this object runs in.
 void setProviders(java.util.List newList)
          Sets the AuthenticationProvider objects to be used for authentication.
 void setSessionController(ConcurrentSessionController sessionController)
          Set the ConcurrentSessionController to be used for limiting user's sessions.
 
Methods inherited from class org.acegisecurity.AbstractAuthenticationManager
authenticate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final org.apache.commons.logging.Log logger

applicationEventPublisher

private org.springframework.context.ApplicationEventPublisher applicationEventPublisher

sessionController

private ConcurrentSessionController sessionController

providers

private java.util.List providers

messages

protected org.springframework.context.support.MessageSourceAccessor messages

exceptionMappings

private java.util.Properties exceptionMappings
Constructor Detail

ProviderManager

public ProviderManager()
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Description copied from interface: org.springframework.beans.factory.InitializingBean
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).

This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.

Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean

checkIfValidList

private void checkIfValidList(java.util.List listToCheck)

doAddExtraDefaultExceptionMappings

protected void doAddExtraDefaultExceptionMappings(java.util.Properties exceptionMappings)
Provided so subclasses can add extra exception mappings during startup if no exception mappings are injected by the IoC container.


doAuthentication

public org.acegisecurity.Authentication doAuthentication(org.acegisecurity.Authentication authentication)
                                                  throws org.acegisecurity.AuthenticationException
Attempts to authenticate the passed org.acegisecurity.Authentication object.

The list of AuthenticationProviders will be successively tried until an AuthenticationProvider indicates it is capable of authenticating the type of Authentication object passed. Authentication will then be attempted with that AuthenticationProvider.

If more than one AuthenticationProvider supports the passed Authentication object, only the first AuthenticationProvider tried will determine the result. No subsequent AuthenticationProviders will be tried.


getProviders

public java.util.List getProviders()

getSessionController

public ConcurrentSessionController getSessionController()
The configured ConcurrentSessionController is returned or the NullConcurrentSessionController if a specific one has not been set.


setApplicationEventPublisher

public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
Description copied from interface: org.springframework.context.ApplicationEventPublisherAware
Set the ApplicationEventPublisher that this object runs in.

Invoked after population of normal bean properties but before an init callback like InitializingBean's afterPropertiesSet or a custom init-method. Invoked before ApplicationContextAware's setApplicationContext.

Specified by:
setApplicationEventPublisher in interface org.springframework.context.ApplicationEventPublisherAware

setMessageSource

public void setMessageSource(org.springframework.context.MessageSource messageSource)
Description copied from interface: org.springframework.context.MessageSourceAware
Set the MessageSource that this object runs in.

Invoked after population of normal bean properties but before an init callback like InitializingBean's afterPropertiesSet or a custom init-method. Invoked before ApplicationContextAware's setApplicationContext.

Specified by:
setMessageSource in interface org.springframework.context.MessageSourceAware

setProviders

public void setProviders(java.util.List newList)
Sets the AuthenticationProvider objects to be used for authentication.


setSessionController

public void setSessionController(ConcurrentSessionController sessionController)
Set the ConcurrentSessionController to be used for limiting user's sessions. The NullConcurrentSessionController is used by default