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

Quick Search    Search Deep

org.acegisecurity.runas
Class RunAsManagerImpl  view RunAsManagerImpl download RunAsManagerImpl.java

java.lang.Object
  extended byorg.acegisecurity.runas.RunAsManagerImpl
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean, org.acegisecurity.RunAsManager

public class RunAsManagerImpl
extends java.lang.Object
implements org.acegisecurity.RunAsManager, org.springframework.beans.factory.InitializingBean

Basic concrete implementation of a org.acegisecurity.RunAsManager.

Is activated if any ConfigAttribute#getAttribute() is prefixed with RUN_AS_. If found, it generates a new RunAsUserToken containing the same principal, credentials and granted authorities as the original org.acegisecurity.Authentication object, along with GrantedAuthorityImpls for each RUN_AS_ indicated. The created GrantedAuthorityImpls will be prefixed with a special prefix indicating that it is a role (default prefix value is ROLE_), and then the remainder of the RUN_AS_ keyword. For example, RUN_AS_FOO will result in the creation of a granted authority of ROLE_RUN_AS_FOO.

The role prefix may be overriden from the default, to match that used elsewhere, for example when using an existing role database with another prefix. An empty role prefix may also be specified. Note however that there are potential issues with using an empty role prefix since different categories of org.acegisecurity.ConfigAttribute can not be properly discerned based on the prefix, with possible consequences when performing voting and other actions. However, this option may be of some use when using preexisting role names without a prefix, and no ability exists to prefix them with a role prefix on reading them in, such as provided for example in org.acegisecurity.userdetails.jdbc.JdbcDaoImpl.

Version:
$Id: RunAsManagerImpl.java,v 1.8 2005/11/29 13:10:14 benalex Exp $

Field Summary
private  java.lang.String key
           
private  java.lang.String rolePrefix
           
 
Constructor Summary
RunAsManagerImpl()
           
 
Method Summary
 void afterPropertiesSet()
          Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
 org.acegisecurity.Authentication buildRunAs(org.acegisecurity.Authentication authentication, java.lang.Object object, ConfigAttributeDefinition config)
          Returns a replacement Authentication object for the current secure object invocation, or null if replacement not required.
 java.lang.String getKey()
           
 java.lang.String getRolePrefix()
           
 void setKey(java.lang.String key)
           
 void setRolePrefix(java.lang.String rolePrefix)
          Allows the default role prefix of ROLE_ to be overriden.
 boolean supports(ConfigAttribute attribute)
          Indicates whether this RunAsManager is able to process the passed ConfigAttribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

key

private java.lang.String key

rolePrefix

private java.lang.String rolePrefix
Constructor Detail

RunAsManagerImpl

public RunAsManagerImpl()
Method Detail

setKey

public void setKey(java.lang.String key)

getKey

public java.lang.String getKey()

setRolePrefix

public void setRolePrefix(java.lang.String rolePrefix)
Allows the default role prefix of ROLE_ to be overriden. May be set to an empty value, although this is usually not desireable.


getRolePrefix

public java.lang.String getRolePrefix()

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

buildRunAs

public org.acegisecurity.Authentication buildRunAs(org.acegisecurity.Authentication authentication,
                                                   java.lang.Object object,
                                                   ConfigAttributeDefinition config)
Description copied from interface: org.acegisecurity.RunAsManager
Returns a replacement Authentication object for the current secure object invocation, or null if replacement not required.

Specified by:
buildRunAs in interface org.acegisecurity.RunAsManager

supports

public boolean supports(ConfigAttribute attribute)
Description copied from interface: org.acegisecurity.RunAsManager
Indicates whether this RunAsManager is able to process the passed ConfigAttribute.

This allows the AbstractSecurityInterceptor to check every configuration attribute can be consumed by the configured AccessDecisionManager and/or RunAsManager and/or AfterInvocationManager.

Specified by:
supports in interface org.acegisecurity.RunAsManager