Class AuthorizationManagerBeforeMethodInterceptor
java.lang.Object
org.springframework.security.authorization.method.AuthorizationManagerBeforeMethodInterceptor
- All Implemented Interfaces:
org.aopalliance.aop.Advice
,org.aopalliance.intercept.Interceptor
,org.aopalliance.intercept.MethodInterceptor
,org.springframework.aop.Advisor
,org.springframework.aop.framework.AopInfrastructureBean
,org.springframework.aop.PointcutAdvisor
,org.springframework.core.Ordered
public final class AuthorizationManagerBeforeMethodInterceptor
extends Object
implements org.springframework.core.Ordered, org.aopalliance.intercept.MethodInterceptor, org.springframework.aop.PointcutAdvisor, org.springframework.aop.framework.AopInfrastructureBean
A
MethodInterceptor
which uses a AuthorizationManager
to determine if
an Authentication
may invoke the given MethodInvocation
- Since:
- 5.6
-
Field Summary
Fields inherited from interface org.springframework.aop.Advisor
EMPTY_ADVICE
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorsConstructorDescriptionAuthorizationManagerBeforeMethodInterceptor
(org.springframework.aop.Pointcut pointcut, AuthorizationManager<org.aopalliance.intercept.MethodInvocation> authorizationManager) Creates an instance. -
Method Summary
Modifier and TypeMethodDescriptionorg.aopalliance.aop.Advice
int
getOrder()
org.springframework.aop.Pointcut
invoke
(org.aopalliance.intercept.MethodInvocation mi) Determine if anAuthentication
has access to theMethodInvocation
using the configuredAuthorizationManager
.boolean
jsr250()
Creates an interceptor for the JSR-250 annotationsjsr250
(Jsr250AuthorizationManager authorizationManager) Creates an interceptor for the JSR-250 annotationsCreates an interceptor for thePreAuthorize
annotationpreAuthorize
(PreAuthorizeAuthorizationManager authorizationManager) Creates an interceptor for thePreAuthorize
annotationsecured()
Creates an interceptor for theSecured
annotationsecured
(SecuredAuthorizationManager authorizationManager) Creates an interceptor for theSecured
annotationvoid
setAuthorizationEventPublisher
(AuthorizationEventPublisher eventPublisher) Use thisAuthorizationEventPublisher
to publish theAuthorizationManager
result.void
setOrder
(int order)
-
Constructor Details
-
AuthorizationManagerBeforeMethodInterceptor
public AuthorizationManagerBeforeMethodInterceptor(org.springframework.aop.Pointcut pointcut, AuthorizationManager<org.aopalliance.intercept.MethodInvocation> authorizationManager) Creates an instance.- Parameters:
pointcut
- thePointcut
to useauthorizationManager
- theAuthorizationManager
to use
-
-
Method Details
-
preAuthorize
Creates an interceptor for thePreAuthorize
annotation- Returns:
- the interceptor
-
preAuthorize
public static AuthorizationManagerBeforeMethodInterceptor preAuthorize(PreAuthorizeAuthorizationManager authorizationManager) Creates an interceptor for thePreAuthorize
annotation- Parameters:
authorizationManager
- thePreAuthorizeAuthorizationManager
to use- Returns:
- the interceptor
-
secured
Creates an interceptor for theSecured
annotation- Returns:
- the interceptor
-
secured
public static AuthorizationManagerBeforeMethodInterceptor secured(SecuredAuthorizationManager authorizationManager) Creates an interceptor for theSecured
annotation- Parameters:
authorizationManager
- theSecuredAuthorizationManager
to use- Returns:
- the interceptor
-
jsr250
Creates an interceptor for the JSR-250 annotations- Returns:
- the interceptor
-
jsr250
public static AuthorizationManagerBeforeMethodInterceptor jsr250(Jsr250AuthorizationManager authorizationManager) Creates an interceptor for the JSR-250 annotations- Parameters:
authorizationManager
- theJsr250AuthorizationManager
to use- Returns:
- the interceptor
-
invoke
Determine if anAuthentication
has access to theMethodInvocation
using the configuredAuthorizationManager
.- Specified by:
invoke
in interfaceorg.aopalliance.intercept.MethodInterceptor
- Parameters:
mi
- theMethodInvocation
to check- Throws:
AccessDeniedException
- if access is not grantedThrowable
-
getOrder
public int getOrder()- Specified by:
getOrder
in interfaceorg.springframework.core.Ordered
-
setOrder
public void setOrder(int order) -
setAuthorizationEventPublisher
Use thisAuthorizationEventPublisher
to publish theAuthorizationManager
result.- Parameters:
eventPublisher
-- Since:
- 5.7
-
getPointcut
public org.springframework.aop.Pointcut getPointcut()- Specified by:
getPointcut
in interfaceorg.springframework.aop.PointcutAdvisor
-
getAdvice
public org.aopalliance.aop.Advice getAdvice()- Specified by:
getAdvice
in interfaceorg.springframework.aop.Advisor
-
isPerInstance
public boolean isPerInstance()- Specified by:
isPerInstance
in interfaceorg.springframework.aop.Advisor
-