@Override
  public void configure(ResourceInfo resourceInfo, FeatureContext configurable) {
    final Class declaring = resourceInfo.getResourceClass();
    final Method method = resourceInfo.getResourceMethod();

    if (declaring == null || method == null) return;

    for (Annotation[] annotations : method.getParameterAnnotations()) {
      String encoding = getEncoding(annotations);
      if (encoding != null) {
        configurable.register(new ClientContentEncodingAnnotationFilter(encoding));
        return;
      }
    }
  }
  public void filter(ContainerRequestContext context) throws IOException {

    Class<?> resourceClass = resourceInfo.getResourceClass();
    if (resourceClass != null) {
      Annotation annotation = fetchAnnotation(resourceClass.getAnnotations());
      if (annotation != null) {
        ANNOTATION_MAP.get(annotation.annotationType()).assertAuthorized(annotation);
      }
    }

    Method method = resourceInfo.getResourceMethod();
    if (method != null) {
      Annotation annotation = fetchAnnotation(method.getAnnotations());
      if (annotation != null) {
        ANNOTATION_MAP.get(annotation.annotationType()).assertAuthorized(annotation);
      }
    }
  }
  @Override
  public void configure(ResourceInfo resourceInfo, FeatureContext featureContext) {
    Method am = resourceInfo.getResourceMethod();

    logger.debug(
        "configure {} method {}",
        resourceInfo.getResourceClass().getSimpleName(),
        resourceInfo.getResourceMethod().getName());

    if (am.isAnnotationPresent(RequireApplicationAccess.class)) {
      featureContext.register(ApplicationFilter.class);
    } else if (am.isAnnotationPresent(RequireOrganizationAccess.class)) {
      featureContext.register(OrganizationFilter.class);
    } else if (am.isAnnotationPresent(RequireSystemAccess.class)) {
      featureContext.register(SystemFilter.class);
    } else if (am.isAnnotationPresent(RequireAdminUserAccess.class)) {
      featureContext.register(SystemFilter.AdminUserFilter.class);
    }
  }
Esempio n. 4
0
  @Override
  public void configure(ResourceInfo resourceInfo, FeatureContext context) {

    Method resourceMethod = resourceInfo.getResourceMethod();
    Class<?> resourceClass = resourceInfo.getResourceClass();
    if (metricsDisabled(resourceClass)) {
      return;
    }
    Path methodPath = resourceMethod.getAnnotation(Path.class);
    Path classPath = resourceClass.getAnnotation(Path.class);

    Path path = methodPath != null ? methodPath : classPath;
    if (path != null) {
      UriBuilder builder =
          methodPath != null
              ? UriBuilder.fromResource(resourceClass).path(resourceClass, resourceMethod.getName())
              : UriBuilder.fromResource(resourceClass);

      String template = builder.toTemplate();
      context.register(new TimerBeforeFilter(template));
      context.register(TimerAfterFilter.class);
    }
  }
 private static boolean classOrResourceAnnotatedWith(
     ResourceInfo resourceInfo, Class<NeverCache> class1) {
   return resourceInfo.getResourceClass().isAnnotationPresent(class1)
       || resourceInfo.getResourceMethod().isAnnotationPresent(class1);
 }