Class RunAsManagerImpl
- java.lang.Object
-
- org.springframework.security.access.intercept.RunAsManagerImpl
-
- All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean,RunAsManager
public class RunAsManagerImpl extends java.lang.Object implements RunAsManager, org.springframework.beans.factory.InitializingBean
Basic concrete implementation of aRunAsManager.Is activated if any
ConfigAttribute.getAttribute()is prefixed withRUN_AS_. If found, it generates a newRunAsUserTokencontaining the same principal, credentials and granted authorities as the originalAuthenticationobject, along withSimpleGrantedAuthoritys for eachRUN_AS_indicated. The createdSimpleGrantedAuthoritys will be prefixed with a special prefix indicating that it is a role (default prefix value isROLE_), and then the remainder of theRUN_AS_keyword. For example,RUN_AS_FOOwill result in the creation of a granted authority ofROLE_RUN_AS_FOO.The role prefix may be overridden 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
ConfigAttributecan 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 pre-existing 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 inJdbcDaoImpl.
-
-
Constructor Summary
Constructors Constructor Description RunAsManagerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()AuthenticationbuildRunAs(Authentication authentication, java.lang.Object object, java.util.Collection<ConfigAttribute> attributes)Returns a replacementAuthenticationobject for the current secure object invocation, ornullif replacement not required.java.lang.StringgetKey()java.lang.StringgetRolePrefix()voidsetKey(java.lang.String key)voidsetRolePrefix(java.lang.String rolePrefix)Allows the default role prefix ofROLE_to be overridden.booleansupports(java.lang.Class<?> clazz)This implementation supports any type of class, because it does not query the presented secure object.booleansupports(ConfigAttribute attribute)Indicates whether thisRunAsManageris able to process the passedConfigAttribute.
-
-
-
Method Detail
-
afterPropertiesSet
public void afterPropertiesSet()
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
buildRunAs
public Authentication buildRunAs(Authentication authentication, java.lang.Object object, java.util.Collection<ConfigAttribute> attributes)
Description copied from interface:RunAsManagerReturns a replacementAuthenticationobject for the current secure object invocation, ornullif replacement not required.- Specified by:
buildRunAsin interfaceRunAsManager- Parameters:
authentication- the caller invoking the secure objectobject- the secured object being calledattributes- the configuration attributes associated with the secure object being invoked- Returns:
- a replacement object to be used for duration of the secure object
invocation, or
nullif theAuthenticationshould be left as is
-
getKey
public java.lang.String getKey()
-
getRolePrefix
public java.lang.String getRolePrefix()
-
setKey
public void setKey(java.lang.String key)
-
setRolePrefix
public void setRolePrefix(java.lang.String rolePrefix)
Allows the default role prefix ofROLE_to be overridden. May be set to an empty value, although this is usually not desirable.- Parameters:
rolePrefix- the new prefix
-
supports
public boolean supports(ConfigAttribute attribute)
Description copied from interface:RunAsManagerIndicates whether thisRunAsManageris able to process the passedConfigAttribute.This allows the
AbstractSecurityInterceptorto check every configuration attribute can be consumed by the configuredAccessDecisionManagerand/orRunAsManagerand/orAfterInvocationManager.- Specified by:
supportsin interfaceRunAsManager- Parameters:
attribute- a configuration attribute that has been configured against theAbstractSecurityInterceptor- Returns:
trueif thisRunAsManagercan support the passed configuration attribute
-
supports
public boolean supports(java.lang.Class<?> clazz)
This implementation supports any type of class, because it does not query the presented secure object.- Specified by:
supportsin interfaceRunAsManager- Parameters:
clazz- the secure object- Returns:
- always
true
-
-