Spring Security Framework

org.springframework.security.intercept.method
Class AbstractFallbackMethodDefinitionSource

java.lang.Object
  extended by org.springframework.security.intercept.method.AbstractFallbackMethodDefinitionSource
All Implemented Interfaces:
MethodDefinitionSource, ObjectDefinitionSource
Direct Known Subclasses:
Jsr250MethodDefinitionSource, MapBasedMethodDefinitionSource, MethodDefinitionAttributes, SecuredMethodDefinitionSource

public abstract class AbstractFallbackMethodDefinitionSource
extends Object
implements MethodDefinitionSource

Abstract implementation of MethodDefinitionSource that supports both Spring AOP and AspectJ and caches configuration attribute resolution from: 1. specific target method; 2. target class; 3. declaring method; 4. declaring class/interface.

This class mimics the behaviour of Spring's AbstractFallbackTransactionAttributeSource class.

Note that this class cannot extract security metadata where that metadata is expressed by way of a target method/class (ie #1 and #2 above) AND the target method/class is encapsulated in another proxy object. Spring Security does not walk a proxy chain to locate the concrete/final target object. Consider making Spring Security your final advisor (so it advises the final target, as opposed to another proxy), move the metadata to declared methods or interfaces the proxy implements, or provide your own replacement MethodDefinitionSource.

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

Constructor Summary
AbstractFallbackMethodDefinitionSource()
           
 
Method Summary
protected abstract  ConfigAttributeDefinition findAttributes(Class clazz)
          Obtains the security metadata registered against the specified class.
protected abstract  ConfigAttributeDefinition findAttributes(Method method, Class targetClass)
          Obtains the security metadata applicable to the specified method invocation.
 ConfigAttributeDefinition getAttributes(Method method, Class targetClass)
           
 ConfigAttributeDefinition getAttributes(Object object)
          Accesses the ConfigAttributeDefinition that applies to a given secure object.
 boolean supports(Class clazz)
          Indicates whether the ObjectDefinitionSource implementation is able to provide ConfigAttributeDefinitions for the indicated secure object type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.security.intercept.ObjectDefinitionSource
getConfigAttributeDefinitions
 

Constructor Detail

AbstractFallbackMethodDefinitionSource

public AbstractFallbackMethodDefinitionSource()
Method Detail

getAttributes

public ConfigAttributeDefinition getAttributes(Object object)
                                        throws IllegalArgumentException
Description copied from interface: ObjectDefinitionSource
Accesses the ConfigAttributeDefinition that applies to a given secure object.

Returns null if no ConfigAttribiteDefinition applies.

Specified by:
getAttributes in interface ObjectDefinitionSource
Parameters:
object - the object being secured
Returns:
the ConfigAttributeDefinition that applies to the passed object
Throws:
IllegalArgumentException - if the passed object is not of a type supported by the ObjectDefinitionSource implementation

supports

public final boolean supports(Class clazz)
Description copied from interface: ObjectDefinitionSource
Indicates whether the ObjectDefinitionSource implementation is able to provide ConfigAttributeDefinitions for the indicated secure object type.

Specified by:
supports in interface ObjectDefinitionSource
Parameters:
clazz - the class that is being queried
Returns:
true if the implementation can process the indicated class

getAttributes

public ConfigAttributeDefinition getAttributes(Method method,
                                               Class targetClass)
Specified by:
getAttributes in interface MethodDefinitionSource

findAttributes

protected abstract ConfigAttributeDefinition findAttributes(Method method,
                                                            Class targetClass)
Obtains the security metadata applicable to the specified method invocation.

Note that the Method.getDeclaringClass() may not equal the targetClass. Both parameters are provided to assist subclasses which may wish to provide advanced capabilities related to method metadata being "registered" against a method even if the target class does not declare the method (i.e. the subclass may only inherit the method).

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)

findAttributes

protected abstract ConfigAttributeDefinition findAttributes(Class clazz)
Obtains the security metadata registered against the specified class.

Subclasses should only return metadata expressed at a class level. Subclasses should NOT aggregate metadata for each method registered against a class, as the abstract superclass will separate invoke findAttributes(Method, Class) for individual methods as appropriate.

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

Spring Security Framework

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