Class Jsr250MethodSecurityMetadataSource
- java.lang.Object
-
- org.springframework.security.access.method.AbstractMethodSecurityMetadataSource
-
- org.springframework.security.access.method.AbstractFallbackMethodSecurityMetadataSource
-
- org.springframework.security.access.annotation.Jsr250MethodSecurityMetadataSource
-
- All Implemented Interfaces:
org.springframework.aop.framework.AopInfrastructureBean
,MethodSecurityMetadataSource
,SecurityMetadataSource
public class Jsr250MethodSecurityMetadataSource extends AbstractFallbackMethodSecurityMetadataSource
Sources method security metadata from major JSR 250 security annotations.- Since:
- 2.0
-
-
Field Summary
-
Fields inherited from class org.springframework.security.access.method.AbstractMethodSecurityMetadataSource
logger
-
-
Constructor Summary
Constructors Constructor Description Jsr250MethodSecurityMetadataSource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Collection<ConfigAttribute>
findAttributes(java.lang.Class<?> clazz)
Obtains the security metadata registered against the specified class.protected java.util.Collection<ConfigAttribute>
findAttributes(java.lang.reflect.Method method, java.lang.Class<?> targetClass)
Obtains the security metadata applicable to the specified method invocation.java.util.Collection<ConfigAttribute>
getAllConfigAttributes()
If available, returns all of theConfigAttribute
s defined by the implementing class.void
setDefaultRolePrefix(java.lang.String defaultRolePrefix)
Sets the default prefix to be added toRolesAllowed
.-
Methods inherited from class org.springframework.security.access.method.AbstractFallbackMethodSecurityMetadataSource
getAttributes
-
Methods inherited from class org.springframework.security.access.method.AbstractMethodSecurityMetadataSource
getAttributes, supports
-
-
-
-
Method Detail
-
setDefaultRolePrefix
public void setDefaultRolePrefix(java.lang.String defaultRolePrefix)
Sets the default prefix to be added to
RolesAllowed
. For example, if@RolesAllowed("ADMIN")
or@RolesAllowed("ADMIN")
is used, then the role ROLE_ADMIN will be used when the defaultRolePrefix is "ROLE_" (default).If null or empty, then no default role prefix is used.
- Parameters:
defaultRolePrefix
- the default prefix to add to roles. Default "ROLE_".
-
findAttributes
protected java.util.Collection<ConfigAttribute> findAttributes(java.lang.Class<?> clazz)
Description copied from class:AbstractFallbackMethodSecurityMetadataSource
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
AbstractFallbackMethodSecurityMetadataSource.findAttributes(Method, Class)
for individual methods as appropriate.- Specified by:
findAttributes
in 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)
Description copied from class:AbstractFallbackMethodSecurityMetadataSource
Obtains the security metadata applicable to the specified method invocation.Note that the
Method.getDeclaringClass()
may not equal thetargetClass
. 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).- Specified by:
findAttributes
in 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)
-
getAllConfigAttributes
public java.util.Collection<ConfigAttribute> getAllConfigAttributes()
Description copied from interface:SecurityMetadataSource
If available, returns all of theConfigAttribute
s defined by the implementing class.This is used by the
AbstractSecurityInterceptor
to perform startup time validation of eachConfigAttribute
configured against it.- Returns:
- the
ConfigAttribute
s ornull
if unsupported
-
-