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,AuthorizationAdvisor
public final class AuthorizationManagerBeforeMethodInterceptor
extends Object
implements AuthorizationAdvisor
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_ADVICEFields 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.AdviceintgetOrder()org.springframework.aop.Pointcut@Nullable Objectinvoke(org.aopalliance.intercept.MethodInvocation mi) Determine if anAuthenticationhas access to theMethodInvocationusing the configuredAuthorizationManager.booleanjsr250()Creates an interceptor for the JSR-250 annotationsjsr250(AuthorizationManager<org.aopalliance.intercept.MethodInvocation> authorizationManager) Creates an interceptor for the JSR-250 annotationsjsr250(Jsr250AuthorizationManager authorizationManager) Creates an interceptor for the JSR-250 annotationsCreates an interceptor for thePreAuthorizeannotationpreAuthorize(AuthorizationManager<org.aopalliance.intercept.MethodInvocation> authorizationManager) Creates an interceptor for thePreAuthorizeannotationpreAuthorize(PreAuthorizeAuthorizationManager authorizationManager) Creates an interceptor for thePreAuthorizeannotationsecured()Creates an interceptor for theSecuredannotationsecured(AuthorizationManager<org.aopalliance.intercept.MethodInvocation> authorizationManager) Creates an interceptor for theSecuredannotationsecured(SecuredAuthorizationManager authorizationManager) Creates an interceptor for theSecuredannotationvoidsetAuthorizationEventPublisher(AuthorizationEventPublisher eventPublisher) Use thisAuthorizationEventPublisherto publish theAuthorizationManagerresult.voidsetOrder(int order) voidsetSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy) Sets theSecurityContextHolderStrategyto use.
-
Constructor Details
-
AuthorizationManagerBeforeMethodInterceptor
public AuthorizationManagerBeforeMethodInterceptor(org.springframework.aop.Pointcut pointcut, AuthorizationManager<org.aopalliance.intercept.MethodInvocation> authorizationManager) Creates an instance.- Parameters:
pointcut- thePointcutto useauthorizationManager- theAuthorizationManagerto use
-
-
Method Details
-
preAuthorize
Creates an interceptor for thePreAuthorizeannotation- Returns:
- the interceptor
-
preAuthorize
public static AuthorizationManagerBeforeMethodInterceptor preAuthorize(PreAuthorizeAuthorizationManager authorizationManager) Creates an interceptor for thePreAuthorizeannotation- Parameters:
authorizationManager- thePreAuthorizeAuthorizationManagerto use- Returns:
- the interceptor
-
preAuthorize
public static AuthorizationManagerBeforeMethodInterceptor preAuthorize(AuthorizationManager<org.aopalliance.intercept.MethodInvocation> authorizationManager) Creates an interceptor for thePreAuthorizeannotation- Parameters:
authorizationManager- theAuthorizationManagerto use- Returns:
- the interceptor
- Since:
- 6.0
-
secured
Creates an interceptor for theSecuredannotation- Returns:
- the interceptor
-
secured
public static AuthorizationManagerBeforeMethodInterceptor secured(SecuredAuthorizationManager authorizationManager) Creates an interceptor for theSecuredannotation- Parameters:
authorizationManager- theSecuredAuthorizationManagerto use- Returns:
- the interceptor
-
secured
public static AuthorizationManagerBeforeMethodInterceptor secured(AuthorizationManager<org.aopalliance.intercept.MethodInvocation> authorizationManager) Creates an interceptor for theSecuredannotation- Parameters:
authorizationManager- theAuthorizationManagerto use- Returns:
- the interceptor
- Since:
- 6.0
-
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- theJsr250AuthorizationManagerto use- Returns:
- the interceptor
-
jsr250
public static AuthorizationManagerBeforeMethodInterceptor jsr250(AuthorizationManager<org.aopalliance.intercept.MethodInvocation> authorizationManager) Creates an interceptor for the JSR-250 annotations- Parameters:
authorizationManager- theAuthorizationManagerto use- Returns:
- the interceptor
- Since:
- 6.0
-
invoke
Determine if anAuthenticationhas access to theMethodInvocationusing the configuredAuthorizationManager.- Specified by:
invokein interfaceorg.aopalliance.intercept.MethodInterceptor- Parameters:
mi- theMethodInvocationto check- Throws:
AccessDeniedException- if access is not grantedThrowable
-
getOrder
public int getOrder()- Specified by:
getOrderin interfaceorg.springframework.core.Ordered
-
setOrder
public void setOrder(int order) -
setAuthorizationEventPublisher
Use thisAuthorizationEventPublisherto publish theAuthorizationManagerresult.- Parameters:
eventPublisher-- Since:
- 5.7
-
getPointcut
public org.springframework.aop.Pointcut getPointcut()- Specified by:
getPointcutin interfaceorg.springframework.aop.PointcutAdvisor
-
getAdvice
public org.aopalliance.aop.Advice getAdvice()- Specified by:
getAdvicein interfaceorg.springframework.aop.Advisor
-
isPerInstance
public boolean isPerInstance()- Specified by:
isPerInstancein interfaceorg.springframework.aop.Advisor
-
setSecurityContextHolderStrategy
public void setSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy) Sets theSecurityContextHolderStrategyto use. The default action is to use theSecurityContextHolderStrategystored inSecurityContextHolder.- Since:
- 5.8
-