Class AuthorizingAnnotationMethodInterceptor
java.lang.Object
org.apache.shiro.aop.MethodInterceptorSupport
org.apache.shiro.aop.AnnotationMethodInterceptor
org.apache.shiro.authz.aop.AuthorizingAnnotationMethodInterceptor
- All Implemented Interfaces:
MethodInterceptor
- Direct Known Subclasses:
AuthenticatedAnnotationMethodInterceptor,GuestAnnotationMethodInterceptor,PermissionAnnotationMethodInterceptor,RoleAnnotationMethodInterceptor,UserAnnotationMethodInterceptor
An AnnotationMethodInterceptor that asserts the calling code is authorized to execute the method
before allowing the invocation to continue by inspecting code annotations to perform an access control check.
- Since:
- 0.1
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor that ensures the internalhandleris set which will be used to perform the authorization assertion checks when a supported annotation is encountered.AuthorizingAnnotationMethodInterceptor(AuthorizingAnnotationHandler handler, AnnotationResolver resolver) -
Method Summary
Modifier and TypeMethodDescriptionvoidEnsures the calling Subject is authorized to execute the specifiedMethodInvocation.invoke(MethodInvocation methodInvocation) Ensures themethodInvocationis allowed to execute first before proceeding by calling theassertAuthorizedmethod first.Methods inherited from class org.apache.shiro.aop.AnnotationMethodInterceptor
getAnnotation, getHandler, getResolver, setHandler, setResolver, supportsMethods inherited from class org.apache.shiro.aop.MethodInterceptorSupport
getSubject
-
Constructor Details
-
AuthorizingAnnotationMethodInterceptor
Constructor that ensures the internalhandleris set which will be used to perform the authorization assertion checks when a supported annotation is encountered.- Parameters:
handler- the internalhandlerused to perform authorization assertion checks when a supported annotation is encountered.
-
AuthorizingAnnotationMethodInterceptor
public AuthorizingAnnotationMethodInterceptor(AuthorizingAnnotationHandler handler, AnnotationResolver resolver) - Parameters:
handler-resolver-- Since:
- 1.1
-
-
Method Details
-
invoke
Ensures themethodInvocationis allowed to execute first before proceeding by calling theassertAuthorizedmethod first.- Parameters:
methodInvocation- the method invocation to check for authorization prior to allowing it to proceed/execute.- Returns:
- the return value from the method invocation
(the value of
MethodInvocation.proceed()). - Throws:
AuthorizationException- if theMethodInvocationis not allowed to proceed.Throwable- if any other error occurs.
-
assertAuthorized
Ensures the calling Subject is authorized to execute the specifiedMethodInvocation. As this is an AnnotationMethodInterceptor, this implementation merely delegates to the internalAuthorizingAnnotationHandlerby first acquiring the annotation by callinggetAnnotation(methodInvocation)and then callshandler.assertAuthorized(annotation).- Parameters:
mi- theMethodInvocationto check to see if it is allowed to proceed/execute.- Throws:
AuthorizationException- if the method invocation is not allowed to continue/execute.
-