/** * @param resolver * @since 1.1 */ public PermissionAnnotationMethodInterceptor(AnnotationResolver resolver) { super( new PermissionAnnotationHandler(), resolver); }
/** * Default no-argument constructor that ensures this interceptor looks for * {@link org.apache.shiro.authz.annotation.RequiresPermissions RequiresPermissions} annotations in a method declaration. */ public PermissionAnnotationMethodInterceptor() { super( new PermissionAnnotationHandler() ); }
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); }
@Test(expected = UnauthenticatedException.class) public void testGuestMultiplePermissionAssertion() throws Throwable { PermissionAnnotationHandler handler = new PermissionAnnotationHandler(); Annotation requiresPermissionAnnotation = new RequiresPermissions() { public String[] value() { return new String[]{"test:test", "test2:test2"}; } public Class<? extends Annotation> annotationType() { return RequiresPermissions.class; } public Logical logical() { return Logical.AND; } }; handler.assertAuthorized(requiresPermissionAnnotation); }
@Test(expected = UnauthenticatedException.class) public void testGuestSinglePermissionAssertion() throws Throwable { PermissionAnnotationHandler handler = new PermissionAnnotationHandler(); Annotation requiresPermissionAnnotation = new RequiresPermissions() { public String[] value() { return new String[]{"test:test"}; } public Class<? extends Annotation> annotationType() { return RequiresPermissions.class; } public Logical logical() { return Logical.AND; } }; handler.assertAuthorized(requiresPermissionAnnotation); }
/** * Default no-argument constructor that ensures this interceptor looks for * {@link org.apache.shiro.authz.annotation.RequiresPermissions RequiresPermissions} annotations in a method declaration. */ public PermissionAnnotationMethodInterceptor() { super( new PermissionAnnotationHandler() ); }
/** * @param resolver * @since 1.1 */ public PermissionAnnotationMethodInterceptor(AnnotationResolver resolver) { super( new PermissionAnnotationHandler(), resolver); }
/** * Default no-argument constructor that ensures this interceptor looks for * {@link org.apache.shiro.authz.annotation.RequiresPermissions RequiresPermissions} annotations in a method declaration. */ public PermissionAnnotationMethodInterceptor() { super( new PermissionAnnotationHandler() ); }
/** * @param resolver * @since 1.1 */ public PermissionAnnotationMethodInterceptor(AnnotationResolver resolver) { super( new PermissionAnnotationHandler(), 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); }