Class MapBasedMethodSecurityMetadataSource
- java.lang.Object
-
- org.springframework.security.access.method.AbstractMethodSecurityMetadataSource
-
- org.springframework.security.access.method.AbstractFallbackMethodSecurityMetadataSource
-
- org.springframework.security.access.method.MapBasedMethodSecurityMetadataSource
-
- All Implemented Interfaces:
org.springframework.aop.framework.AopInfrastructureBean,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanClassLoaderAware,MethodSecurityMetadataSource,SecurityMetadataSource
public class MapBasedMethodSecurityMetadataSource extends AbstractFallbackMethodSecurityMetadataSource implements org.springframework.beans.factory.BeanClassLoaderAware
Stores a list of ConfigAttributes for a method or class signature.This class is the preferred implementation of
MethodSecurityMetadataSourcefor XML-based definition of method security metadata. To assist in XML-based definition, wildcard support is provided.- Since:
- 2.0
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<org.springframework.security.access.method.MapBasedMethodSecurityMetadataSource.RegisteredMethod,java.util.List<ConfigAttribute>>methodMapMap from RegisteredMethod to ConfigAttribute list-
Fields inherited from class org.springframework.security.access.method.AbstractMethodSecurityMetadataSource
logger
-
-
Constructor Summary
Constructors Constructor Description MapBasedMethodSecurityMetadataSource()MapBasedMethodSecurityMetadataSource(java.util.Map<java.lang.String,java.util.List<ConfigAttribute>> methodMap)Creates the MapBasedMethodSecurityMetadataSource from a
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSecureMethod(java.lang.Class<?> javaType, java.lang.reflect.Method method, java.util.List<ConfigAttribute> attr)Adds configuration attributes for a specific method, for example where the method has been matched using a pointcut expression.voidaddSecureMethod(java.lang.Class<?> javaType, java.lang.String mappedName, java.util.List<ConfigAttribute> attr)Add configuration attributes for a secure method.protected java.util.Collection<ConfigAttribute>findAttributes(java.lang.Class<?> clazz)Implementation does not support class-level attributes.protected java.util.Collection<ConfigAttribute>findAttributes(java.lang.reflect.Method method, java.lang.Class<?> targetClass)Will walk the method inheritance tree to find the most specific declaration applicable.java.util.Collection<ConfigAttribute>getAllConfigAttributes()Obtains the configuration attributes explicitly defined against this bean.intgetMethodMapSize()voidsetBeanClassLoader(java.lang.ClassLoader beanClassLoader)-
Methods inherited from class org.springframework.security.access.method.AbstractFallbackMethodSecurityMetadataSource
getAttributes
-
Methods inherited from class org.springframework.security.access.method.AbstractMethodSecurityMetadataSource
getAttributes, supports
-
-
-
-
Field Detail
-
methodMap
protected final java.util.Map<org.springframework.security.access.method.MapBasedMethodSecurityMetadataSource.RegisteredMethod,java.util.List<ConfigAttribute>> methodMap
Map from RegisteredMethod to ConfigAttribute list
-
-
Constructor Detail
-
MapBasedMethodSecurityMetadataSource
public MapBasedMethodSecurityMetadataSource()
-
MapBasedMethodSecurityMetadataSource
public MapBasedMethodSecurityMetadataSource(java.util.Map<java.lang.String,java.util.List<ConfigAttribute>> methodMap)
Creates the MapBasedMethodSecurityMetadataSource from a- Parameters:
methodMap- map of method names to ConfigAttributes.
-
-
Method Detail
-
findAttributes
protected java.util.Collection<ConfigAttribute> findAttributes(java.lang.Class<?> clazz)
Implementation does not support class-level attributes.- Specified by:
findAttributesin classAbstractFallbackMethodSecurityMetadataSource- Parameters:
clazz- the target class for the invocation (nevernull)- Returns:
- the security metadata (or null if no metadata applies)
-
findAttributes
protected java.util.Collection<ConfigAttribute> findAttributes(java.lang.reflect.Method method, java.lang.Class<?> targetClass)
Will walk the method inheritance tree to find the most specific declaration applicable.- Specified by:
findAttributesin classAbstractFallbackMethodSecurityMetadataSource- Parameters:
method- the method for the current invocation (nevernull)targetClass- the target class for the invocation (may benull)- Returns:
- the security metadata (or null if no metadata applies)
-
addSecureMethod
public void addSecureMethod(java.lang.Class<?> javaType, java.lang.String mappedName, java.util.List<ConfigAttribute> attr)Add configuration attributes for a secure method. Mapped method names can end or start with*for matching multiple methods.- Parameters:
javaType- target interface or class the security configuration attribute applies tomappedName- mapped method name, which the javaType has declared or inheritedattr- required authorities associated with the method
-
addSecureMethod
public void addSecureMethod(java.lang.Class<?> javaType, java.lang.reflect.Method method, java.util.List<ConfigAttribute> attr)Adds configuration attributes for a specific method, for example where the method has been matched using a pointcut expression. If a match already exists in the map for the method, then the existing match will be retained, so that if this method is called for a more general pointcut it will not override a more specific one which has already been added.This method should only be called during initialization of the
BeanFactory.
-
getAllConfigAttributes
public java.util.Collection<ConfigAttribute> getAllConfigAttributes()
Obtains the configuration attributes explicitly defined against this bean.- Specified by:
getAllConfigAttributesin interfaceSecurityMetadataSource- Returns:
- the attributes explicitly defined against this bean
-
setBeanClassLoader
public void setBeanClassLoader(java.lang.ClassLoader beanClassLoader)
- Specified by:
setBeanClassLoaderin interfaceorg.springframework.beans.factory.BeanClassLoaderAware
-
getMethodMapSize
public int getMethodMapSize()
- Returns:
- map size (for unit tests and diagnostics)
-
-