Spring Security Framework

org.springframework.security.intercept.method
Class MapBasedMethodDefinitionSource

java.lang.Object
  extended by org.springframework.security.intercept.method.AbstractFallbackMethodDefinitionSource
      extended by org.springframework.security.intercept.method.MapBasedMethodDefinitionSource
All Implemented Interfaces:
BeanClassLoaderAware, MethodDefinitionSource, ObjectDefinitionSource

public class MapBasedMethodDefinitionSource
extends AbstractFallbackMethodDefinitionSource
implements BeanClassLoaderAware

Stores a ConfigAttributeDefinition for a method or class signature.

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

Since:
2.0
Version:
$Id$
Author:
Ben Alex

Field Summary
protected  Map methodMap
          Map from RegisteredMethod to ConfigAttributeDefinition
 
Constructor Summary
MapBasedMethodDefinitionSource()
           
MapBasedMethodDefinitionSource(Map methodMap)
          Creates the MapBasedMethodDefinitionSource from a
 
Method Summary
 void addSecureMethod(Class javaType, Method method, ConfigAttributeDefinition 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, ConfigAttributeDefinition attr)
          Add configuration attributes for a secure method.
 void addSecureMethod(String name, ConfigAttributeDefinition attr)
          Add configuration attributes for a secure method.
protected  ConfigAttributeDefinition findAttributes(Class clazz)
          Implementation does not support class-level attributes.
protected  ConfigAttributeDefinition findAttributes(Method method, Class targetClass)
          Will walk the method inheritance tree to find the most specific declaration applicable.
 Collection getConfigAttributeDefinitions()
          Obtains the configuration attributes explicitly defined against this bean.
 int getMethodMapSize()
           
 void setBeanClassLoader(ClassLoader beanClassLoader)
           
 
Methods inherited from class org.springframework.security.intercept.method.AbstractFallbackMethodDefinitionSource
getAttributes, getAttributes, supports
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

methodMap

protected Map methodMap
Map from RegisteredMethod to ConfigAttributeDefinition

Constructor Detail

MapBasedMethodDefinitionSource

public MapBasedMethodDefinitionSource()

MapBasedMethodDefinitionSource

public MapBasedMethodDefinitionSource(Map methodMap)
Creates the MapBasedMethodDefinitionSource from a

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

findAttributes

protected ConfigAttributeDefinition findAttributes(Class clazz)
Implementation does not support class-level attributes.

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

findAttributes

protected ConfigAttributeDefinition findAttributes(Method method,
                                                   Class targetClass)
Will walk the method inheritance tree to find the most specific declaration applicable.

Specified by:
findAttributes in class AbstractFallbackMethodDefinitionSource
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(String name,
                            ConfigAttributeDefinition attr)
Add configuration attributes for a secure method. Method names can end or start with * for matching multiple methods.

Parameters:
name - type and method name, separated by a dot
attr - required authorities associated with the method

addSecureMethod

public void addSecureMethod(Class javaType,
                            String mappedName,
                            ConfigAttributeDefinition 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,
                            ConfigAttributeDefinition 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


getConfigAttributeDefinitions

public Collection getConfigAttributeDefinitions()
Obtains the configuration attributes explicitly defined against this bean.

Specified by:
getConfigAttributeDefinitions in interface ObjectDefinitionSource
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)

Spring Security Framework

Copyright © 2004-2010 SpringSource, Inc. All Rights Reserved.