org.springframework.security.access.method
Class MapBasedMethodSecurityMetadataSource

java.lang.Object
  extended by org.springframework.security.access.method.AbstractMethodSecurityMetadataSource
      extended by org.springframework.security.access.method.AbstractFallbackMethodSecurityMetadataSource
          extended by org.springframework.security.access.method.MapBasedMethodSecurityMetadataSource
All Implemented Interfaces:
AopInfrastructureBean, Aware, BeanClassLoaderAware, MethodSecurityMetadataSource, SecurityMetadataSource

public class MapBasedMethodSecurityMetadataSource
extends AbstractFallbackMethodSecurityMetadataSource
implements BeanClassLoaderAware

Stores a list of ConfigAttributes for a method or class signature.

This class is the preferred implementation of MethodSecurityMetadataSource for XML-based definition of method security metadata. To assist in XML-based definition, wildcard support is provided.

Since:
2.0

Field Summary
protected  Map<org.springframework.security.access.method.MapBasedMethodSecurityMetadataSource.RegisteredMethod,List<ConfigAttribute>> methodMap
          Map from RegisteredMethod to ConfigAttribute list
 
Fields inherited from class org.springframework.security.access.method.AbstractMethodSecurityMetadataSource
logger
 
Constructor Summary
MapBasedMethodSecurityMetadataSource()
           
MapBasedMethodSecurityMetadataSource(Map<String,List<ConfigAttribute>> methodMap)
          Creates the MapBasedMethodSecurityMetadataSource from a
 
Method Summary
 void addSecureMethod(Class<?> javaType, Method method, List<ConfigAttribute> attr)
          Adds configuration attributes for a specific method, for example where the method has been matched using a pointcut expression.
 void addSecureMethod(Class<?> javaType, String mappedName, List<ConfigAttribute> attr)
          Add configuration attributes for a secure method.
protected  Collection<ConfigAttribute> findAttributes(Class<?> clazz)
          Implementation does not support class-level attributes.
protected  Collection<ConfigAttribute> findAttributes(Method method, Class<?> targetClass)
          Will walk the method inheritance tree to find the most specific declaration applicable.
 Collection<ConfigAttribute> getAllConfigAttributes()
          Obtains the configuration attributes explicitly defined against this bean.
 int getMethodMapSize()
           
 void setBeanClassLoader(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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

methodMap

protected final Map<org.springframework.security.access.method.MapBasedMethodSecurityMetadataSource.RegisteredMethod,List<ConfigAttribute>> methodMap
Map from RegisteredMethod to ConfigAttribute list

Constructor Detail

MapBasedMethodSecurityMetadataSource

public MapBasedMethodSecurityMetadataSource()

MapBasedMethodSecurityMetadataSource

public MapBasedMethodSecurityMetadataSource(Map<String,List<ConfigAttribute>> methodMap)
Creates the MapBasedMethodSecurityMetadataSource from a

Parameters:
methodMap - map of method names to ConfigAttributes.
Method Detail

findAttributes

protected Collection<ConfigAttribute> findAttributes(Class<?> clazz)
Implementation does not support class-level attributes.

Specified by:
findAttributes in class AbstractFallbackMethodSecurityMetadataSource
Parameters:
clazz - the target class for the invocation (never null)
Returns:
the security metadata (or null if no metadata applies)

findAttributes

protected Collection<ConfigAttribute> findAttributes(Method method,
                                                     Class<?> targetClass)
Will walk the method inheritance tree to find the most specific declaration applicable.

Specified by:
findAttributes in class AbstractFallbackMethodSecurityMetadataSource
Parameters:
method - the method for the current invocation (never null)
targetClass - the target class for the invocation (may be null)
Returns:
the security metadata (or null if no metadata applies)

addSecureMethod

public void addSecureMethod(Class<?> javaType,
                            String mappedName,
                            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 to
mappedName - mapped method name, which the javaType has declared or inherited
attr - required authorities associated with the method

addSecureMethod

public void addSecureMethod(Class<?> javaType,
                            Method method,
                            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 Collection<ConfigAttribute> getAllConfigAttributes()
Obtains the configuration attributes explicitly defined against this bean.

Specified by:
getAllConfigAttributes in interface SecurityMetadataSource
Returns:
the attributes explicitly defined against this bean

setBeanClassLoader

public void setBeanClassLoader(ClassLoader beanClassLoader)
Specified by:
setBeanClassLoader in interface BeanClassLoaderAware

getMethodMapSize

public int getMethodMapSize()
Returns:
map size (for unit tests and diagnostics)