Refine search
@Override public void configure(ResourceInfo resourceInfo, FeatureContext context) { final Class<?> resourceClass = resourceInfo.getResourceClass(); final Method resourceMethod = resourceInfo.getResourceMethod(); if (serverStatus.hasCapability(ServerStatus.Capability.MASTER)) return; if (resourceMethod.isAnnotationPresent(RestrictToMaster.class) || resourceClass.isAnnotationPresent(RestrictToMaster.class)) { context.register(restrictToMasterFilter); } } }
/** * Invoked prior to request invocation during {@link ContainerRequestFilter#filter(ContainerRequestContext)} * where the resource info was injected from context. * * <p>Adds the tags {@link #RESOURCE_CLASS} and {@link #RESOURCE_METHOD}. Override or use {@link #NOOP} * to change this behavior. */ protected void resourceInfo(ResourceInfo resourceInfo, SpanCustomizer customizer) { customizer.tag(RESOURCE_CLASS, resourceInfo.getResourceClass().getSimpleName()); customizer.tag(RESOURCE_METHOD, resourceInfo.getResourceMethod().getName()); }
@Override public void configure(ResourceInfo resourceInfo, FeatureContext context) { if (resourceInfo.getResourceMethod().getAnnotation(DateRequired.class) != null) { context.register(DateNotSpecifiedFilter.class); } } }
@Override public void configure(ResourceInfo resourceInfo, FeatureContext configurable) { @SuppressWarnings("rawtypes") final Class declaring = resourceInfo.getResourceClass(); final Method method = resourceInfo.getResourceMethod(); if (declaring == null || method == null) return; Set<String> encodings = getEncodings(method.getAnnotations()); if (encodings.size() <= 0) { encodings = getEncodings(declaring.getAnnotations()); if (encodings.size() <= 0) return; } // check if GZIP encoder has been registered if (!isGZipRegistered(configurable.getConfiguration())) { encodings.remove("gzip"); } configurable.register(createFilter(encodings)); }
@Override public void configure(ResourceInfo resourceInfo, FeatureContext context) { if (DynamicallyBoundFilterResource.class == resourceInfo.getResourceClass()) { context.register(DynamicallyBoundFilter.class); } } }
public MeteredMetricsFilter(MetricRegistry metricRegistry, ResourceInfo resourceInfo) { final Metered annotation = resourceInfo.getResourceMethod().getAnnotation(Metered.class); meter = metricRegistry.meter(chooseName(annotation.name(), annotation.absolute(), resourceInfo.getResourceMethod())); } @Override
private SecurityDefinition getMethodSecurity(Method definitionMethod) { // Check cache if (resourceMethodSecurity.containsKey(definitionMethod)) { return resourceMethodSecurity.get(definitionMethod); } // Jersey model 'definition method' is the method that contains JAX-RS/Jersey annotations. JAX-RS does not support // merging annotations from a parent, so we don't have to look for annotations on corresponding methods of interfaces // and abstract classes implemented by the definition method. // Jersey model does not have a 'definition class', so we have to find it from a handler class Class<?> definitionClass = getDefinitionClass(resourceInfo.getResourceClass()); SecurityDefinition definition = this.resourceClassSecurity .computeIfAbsent(definitionClass, aClass -> securityForClass(definitionClass, appWideSecurity)); Authenticated atn = definitionMethod.getAnnotation(Authenticated.class); Authorized atz = definitionMethod.getAnnotation(Authorized.class); Audited audited = definitionMethod.getAnnotation(Audited.class); SecurityDefinition methodDef = definition.copyMe(); methodDef.add(atn); methodDef.add(atz); methodDef.add(audited); addCustomAnnotations(methodDef.getOperationScope(), definitionMethod); resourceMethodSecurity.put(definitionMethod, methodDef); for (AnnotationAnalyzer analyzer : analyzers) { AnnotationAnalyzer.AnalyzerResponse analyzerResponse = analyzer.analyze(definitionMethod, definition.analyzerResponse(analyzer)); methodDef.analyzerResponse(analyzer, analyzerResponse); } return methodDef; }
@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)); } }
Class<?> resourceClass = resourceInfo.getResourceClass(); List<Role> classRoles = extractRoles(resourceClass); Method resourceMethod = resourceInfo.getResourceMethod(); List<Role> methodRoles = extractRoles(resourceMethod);
@Override public void configure(ResourceInfo resourceInfo, FeatureContext context) { if (DynamicallyBoundInterceptorResource.class == resourceInfo.getResourceClass()) { context.register(DynamicallyBoundInterceptor.class); } } }
public TimedMetricsFilter(MetricRegistry metricRegistry, ResourceInfo resourceInfo) { final Timed annotation = resourceInfo.getResourceMethod().getAnnotation(Timed.class); timer = metricRegistry.timer(chooseName(annotation.name(), annotation.absolute(), resourceInfo.getResourceMethod())); }
.getProducibleMediaTypes(requestProvider.get(), extendedUriInfoProvider.get(), null); final Class<?> resourceClass = resourceInfoProvider.get().getResourceClass(); if (viewable instanceof ImplicitViewable) {
@Override public void configure(ResourceInfo resourceInfo, FeatureContext context) { if (resourceInfo.getResourceClass().getName().indexOf("scouterx.") == 0) { if (resourceInfo.getResourceMethod().getAnnotation(NoAuth.class) == null) { context.register(AuthFilter.class); } } } }
@Override public void configure(ResourceInfo resourceInfo, FeatureContext context) { final Require va = resourceInfo.getResourceMethod().getAnnotation(Require.class); if (va != null) { context.register(new CustomHeaderFilter(va.headerName(), va.headerValue())); } } }
@Provider @Priority(Priorities.AUTHORIZATION) public class MyFilter implements ContainerRequestFilter @Context // request scoped proxy private ResourceInfo resourceInfo; @Override public void filter(ContainerRequestContext requestContext) throws IOException { if (resourceInfo.getResourceClass().isAnnotationPresent(MyAnnotationion.class) || resourceInfo.getResourceMethod().isAnnotationPresent(MyOtherAnnotation.class)) {
@Override public void configure(ResourceInfo resourceInfo, FeatureContext context) { if (!resourceInfo.getResourceClass().isAnnotationPresent(DoNotCollect.class) && ! metricsDisabled(resourceInfo.getResourceClass())) { context.register(ContainerCollectingFilter.class); } }
public ExceptionMeteredMetricsFilter(MetricRegistry metricRegistry, ResourceInfo resourceInfo) { final ExceptionMetered annotation = resourceInfo.getResourceMethod().getAnnotation(ExceptionMetered.class); meter = metricRegistry.meter(chooseName(annotation.name(), annotation.absolute(), resourceInfo.getResourceMethod(), ExceptionMetered.DEFAULT_NAME_SUFFIX)); exceptionClass = annotation.cause(); }
@Override public void configure(ResourceInfo resourceInfo, FeatureContext context) { Class<?> resourceClass = resourceInfo.getResourceClass(); if(!classes.contains(resourceClass)){ classes.add(resourceClass); log.log(Level.FINEST, "Apiee adding class [{0}]", resourceClass); } } }
@Override public void configure(ResourceInfo resourceInfo, FeatureContext context) { List<Annotation> authzSpecs = new ArrayList<Annotation>(); for (Class<? extends Annotation> annotationClass : shiroAnnotations) { // XXX What is the performance of getAnnotation vs getAnnotations? Annotation classAuthzSpec = resourceInfo.getResourceClass().getAnnotation(annotationClass); Annotation methodAuthzSpec = resourceInfo.getResourceMethod().getAnnotation(annotationClass); if (classAuthzSpec != null) authzSpecs.add(classAuthzSpec); if (methodAuthzSpec != null) authzSpecs.add(methodAuthzSpec); } if (!authzSpecs.isEmpty()) { context.register(new AnnotationAuthorizationFilter(authzSpecs), Priorities.AUTHORIZATION); } }
@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(); if (type == Optional.class) { final ContainerRequestFilter filter = authFilterMap.get(paramType); context.register(new WebApplicationExceptionCatchingFilter(filter)); return; } else { context.register(authFilterMap.get(type)); return;