Package org.apache.shiro.authz.aop
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
public abstract class AuthorizingAnnotationMethodInterceptor extends AnnotationMethodInterceptor
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
Constructors Constructor Description AuthorizingAnnotationMethodInterceptor(AuthorizingAnnotationHandler handler)
Constructor that ensures the internalhandler
is set which will be used to perform the authorization assertion checks when a supported annotation is encountered.AuthorizingAnnotationMethodInterceptor(AuthorizingAnnotationHandler handler, AnnotationResolver resolver)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
assertAuthorized(MethodInvocation mi)
Ensures the calling Subject is authorized to execute the specifiedMethodInvocation
.Object
invoke(MethodInvocation methodInvocation)
Ensures themethodInvocation
is allowed to execute first before proceeding by calling theassertAuthorized
method first.-
Methods inherited from class org.apache.shiro.aop.AnnotationMethodInterceptor
getAnnotation, getHandler, getResolver, setHandler, setResolver, supports
-
Methods inherited from class org.apache.shiro.aop.MethodInterceptorSupport
getSubject
-
-
-
-
Constructor Detail
-
AuthorizingAnnotationMethodInterceptor
public AuthorizingAnnotationMethodInterceptor(AuthorizingAnnotationHandler handler)
Constructor that ensures the internalhandler
is set which will be used to perform the authorization assertion checks when a supported annotation is encountered.- Parameters:
handler
- the internalhandler
used 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 Detail
-
invoke
public Object invoke(MethodInvocation methodInvocation) throws Throwable
Ensures themethodInvocation
is allowed to execute first before proceeding by calling theassertAuthorized
method 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 theMethodInvocation
is not allowed to proceed.Throwable
- if any other error occurs.
-
assertAuthorized
public void assertAuthorized(MethodInvocation mi) throws AuthorizationException
Ensures the calling Subject is authorized to execute the specifiedMethodInvocation
. As this is an AnnotationMethodInterceptor, this implementation merely delegates to the internalAuthorizingAnnotationHandler
by first acquiring the annotation by callinggetAnnotation(methodInvocation)
and then callshandler.assertAuthorized(annotation)
.- Parameters:
mi
- theMethodInvocation
to check to see if it is allowed to proceed/execute.- Throws:
AuthorizationException
- if the method invocation is not allowed to continue/execute.
-
-