/** * Create new method list from the given collection of methods. * * The {@link Method#isBridge() bridge methods} and methods declared directly * on the {@link Object} class are filtered out. * * @param methods methods to be included in the method list. */ public MethodList(Collection<Method> methods) { List<AnnotatedMethod> l = new ArrayList<>(methods.size()); for (Method m : methods) { if (!m.isBridge() && m.getDeclaringClass() != Object.class) { l.add(new AnnotatedMethod(m)); } } this.methods = new AnnotatedMethod[l.size()]; this.methods = l.toArray(this.methods); }
/** * Create new method list from the given collection of methods. * * The {@link Method#isBridge() bridge methods} and methods declared directly * on the {@link Object} class are filtered out. * * @param methods methods to be included in the method list. */ public MethodList(Collection<Method> methods) { List<AnnotatedMethod> l = new ArrayList<>(methods.size()); for (Method m : methods) { if (!m.isBridge() && m.getDeclaringClass() != Object.class) { l.add(new AnnotatedMethod(m)); } } this.methods = new AnnotatedMethod[l.size()]; this.methods = l.toArray(this.methods); }
@Override public void configure(final ResourceInfo resourceInfo, final FeatureContext configuration) { final AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod()); // check to see if it has cache control annotation final CacheControl cc = am.getAnnotation(CacheControl.class); if (cc != null) { configuration.register(new CacheControlledResponseFilter(cc)); } }
@Override public void configure(ResourceInfo resourceInfo, FeatureContext context) { final AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod()); final Annotation[][] parameterAnnotations = am.getParameterAnnotations(); final Class<?>[] parameterTypes = am.getParameterTypes();
@Override public void configure(final ResourceInfo resourceInfo, final FeatureContext configuration) { AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod()); // RolesAllowed on the method takes precedence over PermitAll RolesAllowed ra = am.getAnnotation(RolesAllowed.class); if (ra != null) { configuration.register(AuthCheckFilter.INSTANCE); return; } // PermitAll takes precedence over RolesAllowed on the class if (am.isAnnotationPresent(PermitAll.class)) { // Do nothing. return; } // RolesAllowed on the class takes precedence over PermitAll ra = resourceInfo.getResourceClass().getAnnotation(RolesAllowed.class); if (ra != null) { configuration.register(AuthCheckFilter.INSTANCE); } }
new AnnotatedMethod(resource.getInvocable().getDefinitionMethod()));
@Override public void configure(ResourceInfo resourceInfo, FeatureContext context) { final AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod()); final Annotation[][] parameterAnnotations = am.getParameterAnnotations(); final Class<?>[] parameterTypes = am.getParameterTypes(); // First, check for any @Auth annotations on the method. for (int i = 0; i < parameterAnnotations.length; i++) { for (final Annotation annotation : parameterAnnotations[i]) { if (annotation instanceof Auth) { // Optional auth requires that a concrete AuthFilter be provided. if (parameterTypes[i].equals(Optional.class) && authFilter != null) { context.register(new WebApplicationExceptionCatchingFilter(authFilter)); return; } else { registerAuthFilter(context); return; } } } } // Second, check for any authorization annotations on the class or method. // Note that @DenyAll shouldn't be attached to classes. final boolean annotationOnClass = (resourceInfo.getResourceClass().getAnnotation(RolesAllowed.class) != null) || (resourceInfo.getResourceClass().getAnnotation(PermitAll.class) != null); final boolean annotationOnMethod = am.isAnnotationPresent(RolesAllowed.class) || am.isAnnotationPresent(DenyAll.class) || am.isAnnotationPresent(PermitAll.class); if (annotationOnClass || annotationOnMethod) { registerAuthFilter(context); } }
@Override public void configure(final ResourceInfo resourceInfo, final FeatureContext configuration) { final AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod()); // DenyAll on the method take precedence over RolesAllowed and PermitAll if (am.isAnnotationPresent(DenyAll.class)) { configuration.register(new RolesAllowedRequestFilter()); return; } // RolesAllowed on the method takes precedence over PermitAll RolesAllowed ra = am.getAnnotation(RolesAllowed.class); if (ra != null) { configuration.register(new RolesAllowedRequestFilter(ra.value())); return; } // PermitAll takes precedence over RolesAllowed on the class if (am.isAnnotationPresent(PermitAll.class)) { // Do nothing. return; } // DenyAll can't be attached to classes // RolesAllowed on the class takes precedence over PermitAll ra = resourceInfo.getResourceClass().getAnnotation(RolesAllowed.class); if (ra != null) { configuration.register(new RolesAllowedRequestFilter(ra.value())); } }
@Override public void configure(final ResourceInfo resourceInfo, final FeatureContext configuration) { final AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod()); // DenyAll on the method take precedence over RolesAllowed and PermitAll if (am.isAnnotationPresent(DenyAll.class)) { configuration.register(new RolesAllowedRequestFilter()); return; } // RolesAllowed on the method takes precedence over PermitAll RolesAllowed ra = am.getAnnotation(RolesAllowed.class); if (ra != null) { configuration.register(new RolesAllowedRequestFilter(ra.value())); return; } // PermitAll takes precedence over RolesAllowed on the class if (am.isAnnotationPresent(PermitAll.class)) { // Do nothing. return; } // DenyAll can't be attached to classes // RolesAllowed on the class takes precedence over PermitAll ra = resourceInfo.getResourceClass().getAnnotation(RolesAllowed.class); if (ra != null) { configuration.register(new RolesAllowedRequestFilter(ra.value())); } }
/** * Create a list of parameter models for a given Java method handling a resource * method, sub-resource method or a sub-resource locator. * * @param concreteClass concrete resource method handler implementation class. * @param declaringClass the class declaring the handling Java method. * @param javaMethod Java method handling a resource method, sub-resource * method or a sub-resource locator. * @param keepEncoded set to {@code true} to disable automatic decoding * of all the method parameters. (See {@link Encoded}. * @return a list of handling method parameter models. */ public static List<Parameter> create( Class concreteClass, Class declaringClass, Method javaMethod, boolean keepEncoded) { AnnotatedMethod method = new AnnotatedMethod(javaMethod); return create( concreteClass, declaringClass, ((null != method.getAnnotation(Encoded.class)) || keepEncoded), method.getParameterTypes(), method.getGenericParameterTypes(), method.getParameterAnnotations()); }
/** * Create a list of parameter models for a given Java method handling a resource * method, sub-resource method or a sub-resource locator. * * @param concreteClass concrete resource method handler implementation class. * @param declaringClass the class declaring the handling Java method. * @param javaMethod Java method handling a resource method, sub-resource * method or a sub-resource locator. * @param keepEncoded set to {@code true} to disable automatic decoding * of all the method parameters. (See {@link Encoded}. * @return a list of handling method parameter models. */ public static List<Parameter> create( Class concreteClass, Class declaringClass, Method javaMethod, boolean keepEncoded) { AnnotatedMethod method = new AnnotatedMethod(javaMethod); return create( concreteClass, declaringClass, ((null != method.getAnnotation(Encoded.class)) || keepEncoded), method.getParameterTypes(), method.getGenericParameterTypes(), method.getParameterAnnotations()); }
/** * Create new method list from the given collection of methods. * * The {@link Method#isBridge() bridge methods} and methods declared directly * on the {@link Object} class are filtered out. * * @param methods methods to be included in the method list. */ public MethodList(Collection<Method> methods) { List<AnnotatedMethod> l = new ArrayList<>(methods.size()); for (Method m : methods) { if (!m.isBridge() && m.getDeclaringClass() != Object.class) { l.add(new AnnotatedMethod(m)); } } this.methods = new AnnotatedMethod[l.size()]; this.methods = l.toArray(this.methods); }
@Override public void configure(final ResourceInfo resourceInfo, final FeatureContext configuration) { final AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod()); // DenyAll on the method take precedence over RolesAllowed and PermitAll if (am.isAnnotationPresent(DenyAll.class)) { configuration.register(new RolesAllowedRequestFilter()); return; } // RolesAllowed on the method takes precedence over PermitAll RolesAllowed ra = am.getAnnotation(RolesAllowed.class); if (ra != null) { configuration.register(new RolesAllowedRequestFilter(ra.value())); return; } // PermitAll takes precedence over RolesAllowed on the class if (am.isAnnotationPresent(PermitAll.class)) { // Do nothing. return; } // DenyAll can't be attached to classes // RolesAllowed on the class takes precedence over PermitAll ra = resourceInfo.getResourceClass().getAnnotation(RolesAllowed.class); if (ra != null) { configuration.register(new RolesAllowedRequestFilter(ra.value())); } }
/** * Create a list of parameter models for a given Java method handling a resource * method, sub-resource method or a sub-resource locator. * * @param concreteClass concrete resource method handler implementation class. * @param declaringClass the class declaring the handling Java method. * @param javaMethod Java method handling a resource method, sub-resource * method or a sub-resource locator. * @param keepEncoded set to {@code true} to disable automatic decoding * of all the method parameters. (See {@link Encoded}. * @return a list of handling method parameter models. */ public static List<Parameter> create( Class concreteClass, Class declaringClass, Method javaMethod, boolean keepEncoded) { AnnotatedMethod method = new AnnotatedMethod(javaMethod); return create( concreteClass, declaringClass, ((null != method.getAnnotation(Encoded.class)) || keepEncoded), method.getParameterTypes(), method.getGenericParameterTypes(), method.getParameterAnnotations()); }
/** * Create new method list from the given collection of methods. * * The {@link Method#isBridge() bridge methods} and methods declared directly * on the {@link Object} class are filtered out. * * @param methods methods to be included in the method list. */ public MethodList(Collection<Method> methods) { List<AnnotatedMethod> l = new ArrayList<>(methods.size()); for (Method m : methods) { if (!m.isBridge() && m.getDeclaringClass() != Object.class) { l.add(new AnnotatedMethod(m)); } } this.methods = new AnnotatedMethod[l.size()]; this.methods = l.toArray(this.methods); }
/** * Create new method list from the given collection of methods. * * The {@link Method#isBridge() bridge methods} and methods declared directly * on the {@link Object} class are filtered out. * * @param methods methods to be included in the method list. */ public MethodList(Collection<Method> methods) { List<AnnotatedMethod> l = new ArrayList<>(methods.size()); for (Method m : methods) { if (!m.isBridge() && m.getDeclaringClass() != Object.class) { l.add(new AnnotatedMethod(m)); } } this.methods = new AnnotatedMethod[l.size()]; this.methods = l.toArray(this.methods); }
/** * Create new method list from the given collection of methods. * * The {@link Method#isBridge() bridge methods} and methods declared directly * on the {@link Object} class are filtered out. * * @param methods methods to be included in the method list. */ public MethodList(Collection<Method> methods) { List<AnnotatedMethod> l = new ArrayList<>(methods.size()); for (Method m : methods) { if (!m.isBridge() && m.getDeclaringClass() != Object.class) { l.add(new AnnotatedMethod(m)); } } this.methods = new AnnotatedMethod[l.size()]; this.methods = l.toArray(this.methods); }
/** * Create new method list from the given collection of methods. * * The {@link Method#isBridge() bridge methods} and methods declared directly * on the {@link Object} class are filtered out. * * @param methods methods to be included in the method list. */ public MethodList(Collection<Method> methods) { List<AnnotatedMethod> l = new ArrayList<>(methods.size()); for (Method m : methods) { if (!m.isBridge() && m.getDeclaringClass() != Object.class) { l.add(new AnnotatedMethod(m)); } } this.methods = new AnnotatedMethod[l.size()]; this.methods = l.toArray(this.methods); }
@Override public void configure(final ResourceInfo resourceInfo, final FeatureContext context) { final AnnotatedMethod method = new AnnotatedMethod(resourceInfo.getResourceMethod()); final RateLimited rateLimited = method.getAnnotation(RateLimited.class); if (null != rateLimited) { context.register(RateLimit429EnforcerFilter.class); } } }
@Override public void configure(final ResourceInfo resourceInfo, final FeatureContext configuration) { final AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod()); // check to see if it has cache control annotation final CacheControl cc = am.getAnnotation(CacheControl.class); if (cc != null) { configuration.register(new CacheControlledResponseFilter(cc)); } }