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

com.hubspot.singularity.auth.dw.SingularityAuthFeature Maven / Gradle / Ivy

package com.hubspot.singularity.auth.dw;

import com.hubspot.singularity.SingularityUser;
import com.hubspot.singularity.auth.authenticator.SingularityMultiMethodAuthenticator;
import io.dropwizard.auth.Auth;
import io.dropwizard.auth.Authenticator;
import javax.inject.Singleton;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.Feature;
import javax.ws.rs.core.FeatureContext;
import org.glassfish.hk2.api.InjectionResolver;
import org.glassfish.hk2.api.TypeLiteral;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.jersey.server.spi.internal.ValueFactoryProvider;

@javax.ws.rs.ext.Provider
public class SingularityAuthFeature implements Feature {

  @javax.inject.Inject
  SingularityAuthFeature() {}

  @Override
  public boolean configure(FeatureContext context) {
    context.register(
      new AbstractBinder() {

        @Override
        public void configure() {
          bind(SingularityMultiMethodAuthenticator.class)
            .to(
              new TypeLiteral>() {}
            )
            .in(Singleton.class);
          bind(SingularityAuthedUserFactory.class)
            .to(SingularityAuthedUserFactory.class)
            .in(Singleton.class);
          bind(SingularityAuthFactoryProvider.class)
            .to(ValueFactoryProvider.class)
            .in(Singleton.class);
          bind(SingularityAuthParamInjectionResolver.class)
            .to(new TypeLiteral>() {})
            .in(Singleton.class);
        }
      }
    );
    return true;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy