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

com.yammer.dropwizard.jersey.OauthTokenProvider Maven / Gradle / Ivy

package com.yammer.dropwizard.jersey;

import com.google.common.base.Optional;
import com.sun.jersey.api.model.Parameter;
import com.sun.jersey.core.spi.component.ComponentContext;
import com.sun.jersey.core.spi.component.ComponentScope;
import com.sun.jersey.spi.inject.Injectable;
import com.sun.jersey.spi.inject.InjectableProvider;
import com.yammer.dropwizard.BearerToken;

import javax.ws.rs.ext.Provider;

// TODO: 11/14/11  -- test OauthTokenProvider
// TODO: 11/14/11  -- document OauthTokenProvider

@Provider
public class OauthTokenProvider implements InjectableProvider {
    @Override
    public ComponentScope getScope() {
        return ComponentScope.PerRequest;
    }

    @Override
    public Injectable getInjectable(ComponentContext ic,
                                       BearerToken a,
                                       Parameter c) {
        if (c.getParameterClass().isAssignableFrom(Optional.class)) {
            return new OauthTokenInjectable(a.prefix() + ' ');
        }
        return null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy