/** * Default no-argument constructor that ensures this interceptor looks for * {@link org.apache.shiro.authz.annotation.RequiresAuthentication RequiresAuthentication} annotations in a method * declaration. */ public AuthenticatedAnnotationMethodInterceptor() { super(new AuthenticatedAnnotationHandler()); }
/** * Ensures that the calling <code>Subject</code> is authenticated, and if not, throws an * {@link org.apache.shiro.authz.UnauthenticatedException UnauthenticatedException} indicating the method is not allowed to be executed. * * @param a the annotation to inspect * @throws org.apache.shiro.authz.UnauthenticatedException if the calling <code>Subject</code> has not yet * authenticated. */ public void assertAuthorized(Annotation a) throws UnauthenticatedException { if (a instanceof RequiresAuthentication && !getSubject().isAuthenticated() ) { throw new UnauthenticatedException( "The current Subject is not authenticated. Access denied." ); } } }
/** * @param resolver * @since 1.1 */ public AuthenticatedAnnotationMethodInterceptor(AnnotationResolver resolver) { super(new AuthenticatedAnnotationHandler(), resolver); } }
/** * Ensures that the calling <code>Subject</code> is authenticated, and if not, throws an * {@link org.apache.shiro.authz.UnauthenticatedException UnauthenticatedException} indicating the method is not allowed to be executed. * * @param a the annotation to inspect * @throws org.apache.shiro.authz.UnauthenticatedException if the calling <code>Subject</code> has not yet * authenticated. */ public void assertAuthorized(Annotation a) throws UnauthenticatedException { if (a instanceof RequiresAuthentication && !getSubject().isAuthenticated() ) { throw new UnauthenticatedException( "The current Subject is not authenticated. Access denied." ); } } }
private static AuthorizingAnnotationHandler createHandler(Annotation annotation) { Class<?> t = annotation.annotationType(); if (RequiresPermissions.class.equals(t)) return new PermissionAnnotationHandler(); else if (RequiresRoles.class.equals(t)) return new RoleAnnotationHandler(); else if (RequiresUser.class.equals(t)) return new UserAnnotationHandler(); else if (RequiresGuest.class.equals(t)) return new GuestAnnotationHandler(); else if (RequiresAuthentication.class.equals(t)) return new AuthenticatedAnnotationHandler(); else throw new IllegalArgumentException("Cannot create a handler for the unknown for annotation " + t); }
/** * Ensures that the calling <code>Subject</code> is authenticated, and if not, throws an * {@link org.apache.shiro.authz.UnauthenticatedException UnauthenticatedException} indicating the method is not allowed to be executed. * * @param a the annotation to inspect * @throws org.apache.shiro.authz.UnauthenticatedException if the calling <code>Subject</code> has not yet * authenticated. */ public void assertAuthorized(Annotation a) throws UnauthenticatedException { if (a instanceof RequiresAuthentication && !getSubject().isAuthenticated() ) { throw new UnauthenticatedException( "The current Subject is not authenticated. Access denied." ); } } }
/** * Default no-argument constructor that ensures this interceptor looks for * {@link org.apache.shiro.authz.annotation.RequiresAuthentication RequiresAuthentication} annotations in a method * declaration. */ public AuthenticatedAnnotationMethodInterceptor() { super(new AuthenticatedAnnotationHandler()); }
/** * @param resolver * @since 1.1 */ public AuthenticatedAnnotationMethodInterceptor(AnnotationResolver resolver) { super(new AuthenticatedAnnotationHandler(), resolver); } }
/** * Default no-argument constructor that ensures this interceptor looks for * {@link org.apache.shiro.authz.annotation.RequiresAuthentication RequiresAuthentication} annotations in a method * declaration. */ public AuthenticatedAnnotationMethodInterceptor() { super(new AuthenticatedAnnotationHandler()); }
/** * @param resolver * @since 1.1 */ public AuthenticatedAnnotationMethodInterceptor(AnnotationResolver resolver) { super(new AuthenticatedAnnotationHandler(), resolver); } }
private static AuthorizingAnnotationHandler createHandler(Annotation annotation) { Class<?> t = annotation.annotationType(); if (RequiresPermissions.class.equals(t)) return new PermissionAnnotationHandler(); else if (RequiresRoles.class.equals(t)) return new RoleAnnotationHandler(); else if (RequiresUser.class.equals(t)) return new UserAnnotationHandler(); else if (RequiresGuest.class.equals(t)) return new GuestAnnotationHandler(); else if (RequiresAuthentication.class.equals(t)) return new AuthenticatedAnnotationHandler(); else throw new IllegalArgumentException("Cannot create a handler for the unknown for annotation " + t); }