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

io.robe.auth.token.jersey.TokenFeature Maven / Gradle / Ivy

package io.robe.auth.token.jersey;

import io.dropwizard.auth.Auth;
import io.robe.auth.token.TokenAuthenticator;
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;

import javax.inject.Singleton;
import javax.ws.rs.core.Feature;
import javax.ws.rs.core.FeatureContext;

public class TokenFeature implements Feature {

    @Override
    public boolean configure(FeatureContext context) {
        context.register(new AbstractBinder() {
            @Override
            public void configure() {
                bind(TokenAuthenticator.class)
                        .to(TokenAuthenticator.class)
                        .in(Singleton.class);
                bind(TokenFactory.class).to(TokenFactory.class)
                        .in(Singleton.class);
                bind(TokenFactoryProvider.class)
                        .to(ValueFactoryProvider.class)
                        .in(Singleton.class);
                bind(TokenParamInjectionResolver.class)
                        .to(new TypeLiteral>() {
                        })
                        .in(Singleton.class);
            }
        });
        return true;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy