All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.whispersystems.dropwizard.simpleauth.AuthDynamicFeature Maven / Gradle / Ivy

package org.whispersystems.dropwizard.simpleauth;

import org.glassfish.jersey.server.model.AnnotatedMethod;

import javax.ws.rs.container.DynamicFeature;
import javax.ws.rs.container.ResourceInfo;
import javax.ws.rs.core.FeatureContext;
import java.lang.annotation.Annotation;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Optional;

import io.dropwizard.auth.Auth;

public class AuthDynamicFeature implements DynamicFeature {

  private AuthFilter[] authFilters;

  public AuthDynamicFeature(AuthFilter... authFilters) {
    this.authFilters = authFilters;
  }

  @Override
  public void configure(ResourceInfo resourceInfo, FeatureContext context) {
    AnnotatedMethod annotatedMethod       = new AnnotatedMethod(resourceInfo.getResourceMethod());
    Annotation[][]  parameterAnnotations  = annotatedMethod.getParameterAnnotations();
    Class[]      parameterTypes        = annotatedMethod.getParameterTypes      ();
    Type[]          parameterGenericTypes = annotatedMethod.getGenericParameterTypes();

    verifyAuthAnnotations(parameterAnnotations);

    for (int i=0;i 1) {
      throw new IllegalArgumentException("Only one @Auth tag supported per resource method!");
    }
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy