Package org.apache.shiro.authz.aop
Class UserAnnotationHandler
- java.lang.Object
-
- org.apache.shiro.aop.AnnotationHandler
-
- org.apache.shiro.authz.aop.AuthorizingAnnotationHandler
-
- org.apache.shiro.authz.aop.UserAnnotationHandler
-
public class UserAnnotationHandler extends AuthorizingAnnotationHandler
Checks to see if a @RequiresUser
annotation is declared, and if so, ensures the callingSubject
is eitherauthenticated
or remembered via remember me services before allowing access.This annotation essentially ensures that
subject.
.getPrincipal()
!= null- Since:
- 0.9.0
-
-
Field Summary
-
Fields inherited from class org.apache.shiro.aop.AnnotationHandler
annotationClass
-
-
Constructor Summary
Constructors Constructor Description UserAnnotationHandler()
Default no-argument constructor that ensures this handler looks forRequiresUser
annotations.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
assertAuthorized(Annotation a)
Ensures that the callingSubject
is a user, that is, they are eitherauthenticated
or remembered via remember me services before allowing access, and if not, throws anAuthorizingException
indicating access is not allowed.-
Methods inherited from class org.apache.shiro.aop.AnnotationHandler
getAnnotationClass, getSubject, setAnnotationClass
-
-
-
-
Constructor Detail
-
UserAnnotationHandler
public UserAnnotationHandler()
Default no-argument constructor that ensures this handler looks forRequiresUser
annotations.
-
-
Method Detail
-
assertAuthorized
public void assertAuthorized(Annotation a) throws AuthorizationException
Ensures that the callingSubject
is a user, that is, they are eitherauthenticated
or remembered via remember me services before allowing access, and if not, throws anAuthorizingException
indicating access is not allowed.- Specified by:
assertAuthorized
in classAuthorizingAnnotationHandler
- Parameters:
a
- the RequiresUser annotation to check- Throws:
AuthorizationException
- if the callingSubject
is not authenticated or remembered via rememberMe services.
-
-