org.springframework.richclient.security
Class SecurityAwareConfigurer

Show UML class diagram
java.lang.Object
  extended by org.springframework.richclient.security.SecurityAwareConfigurer
All Implemented Interfaces:
EventListener, BeanPostProcessor, ApplicationContextAware, ApplicationListener

public class SecurityAwareConfigurer
extends Object
implements ApplicationListener, ApplicationContextAware, BeanPostProcessor

This class performs two main functions:

  1. It is a bean post-processor that will set the current authentication token on any newly created beans that implement AuthenticationAware.
  2. It listens for application ClientSecurityEvents and updates all the beans in the context that implement either AuthenticationAware or LoginAware according to the event received.
In order for all this to take place, a singleton, non-lazy instance of this class must be defined in the Spring ApplicationContext. This would be done like this:
              <bean id="securityAwareConfigurer"
                   class="org.springframework.richclient.security.SecurityAwareConfigurer"
                   lazy-init="false"/>
 

Author:
Larry Streepy, Andy Depue, Inspiration from Ben Alex
See Also:
AuthenticationAware, LoginAware, ClientSecurityEvent

Constructor Summary
SecurityAwareConfigurer()
           
 
Method Summary
protected  void addToNonSingletonListeners(Object bean)
          Add a non-singleton bean instance to our list for later notification.
protected  void broadcastAuthentication(org.springframework.security.Authentication authentication)
          Broadcast an authentication event to all the AuthenticationAware beans.
protected  void broadcastLogin(org.springframework.security.Authentication authentication)
          Broadcast a Login event to all the LoginAware beans.
protected  void broadcastLogout(org.springframework.security.Authentication authentication)
          Broadcast a Logout event to all the LoginAware beans.
 ApplicationContext getApplicationContext()
          Get the installed application context.
protected  List getBeansToUpdate(Class beanType)
          Construct the list of all the beans we need to update.
protected  List getNonSingletonListeners(Class beanType)
          Get the list of non-singleton beans we have registered that still exist.
 void onApplicationEvent(ApplicationEvent event)
           
 Object postProcessAfterInitialization(Object bean, String beanName)
           
 Object postProcessBeforeInitialization(Object bean, String beanName)
           
 void setApplicationContext(ApplicationContext applicationContext)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecurityAwareConfigurer

public SecurityAwareConfigurer()
Method Detail

getApplicationContext

public ApplicationContext getApplicationContext()
Get the installed application context.

Returns:
context

broadcastAuthentication

protected void broadcastAuthentication(org.springframework.security.Authentication authentication)
Broadcast an authentication event to all the AuthenticationAware beans.

Parameters:
authentication - token

broadcastLogin

protected void broadcastLogin(org.springframework.security.Authentication authentication)
Broadcast a Login event to all the LoginAware beans.

Parameters:
authentication - token

broadcastLogout

protected void broadcastLogout(org.springframework.security.Authentication authentication)
Broadcast a Logout event to all the LoginAware beans.

Parameters:
authentication - token

getBeansToUpdate

protected List getBeansToUpdate(Class beanType)
Construct the list of all the beans we need to update.

Parameters:
beanType - Type of bean to locate
Returns:
List of all beans to udpate.

getNonSingletonListeners

protected List getNonSingletonListeners(Class beanType)
Get the list of non-singleton beans we have registered that still exist. Update our registration list if any have been GC'ed. Only return beans of the requested type.

Parameters:
beanType - Type of bean to locate
Returns:
list of extant non-singleton beans to notify

addToNonSingletonListeners

protected void addToNonSingletonListeners(Object bean)
Add a non-singleton bean instance to our list for later notification.

Parameters:
bean -

onApplicationEvent

public void onApplicationEvent(ApplicationEvent event)
Specified by:
onApplicationEvent in interface ApplicationListener

setApplicationContext

public void setApplicationContext(ApplicationContext applicationContext)
                           throws BeansException
Specified by:
setApplicationContext in interface ApplicationContextAware
Throws:
BeansException

postProcessBeforeInitialization

public Object postProcessBeforeInitialization(Object bean,
                                              String beanName)
                                       throws BeansException
Specified by:
postProcessBeforeInitialization in interface BeanPostProcessor
Throws:
BeansException

postProcessAfterInitialization

public Object postProcessAfterInitialization(Object bean,
                                             String beanName)
                                      throws BeansException
Specified by:
postProcessAfterInitialization in interface BeanPostProcessor
Throws:
BeansException


Copyright © 2004-2009 The Spring Framework. All Rights Reserved.