use of org.glassfish.jersey.server.oauth1.DefaultOAuth1Provider in project jersey by jersey.
the class OAuthClientServerTest method configure.
@Override
protected Application configure() {
final DefaultOAuth1Provider oAuthProvider = new DefaultOAuth1Provider();
oAuthProvider.registerConsumer(CONSUMER_NAME, CONSUMER_KEY, SECRET_CONSUMER_KEY, new MultivaluedHashMap<String, String>());
final Principal prometheusPrincipal = new Principal() {
@Override
public String getName() {
return "prometheus";
}
};
oAuthProvider.addAccessToken(PROMETHEUS_TOKEN, PROMETHEUS_SECRET, CONSUMER_KEY, "http://callback.url", prometheusPrincipal, Arrays.asList("admin", "user").stream().collect(Collectors.toSet()), new MultivaluedHashMap<String, String>());
final OAuth1ServerFeature oAuth1ServerFeature = new OAuth1ServerFeature(oAuthProvider, "requestTokenSpecialUri", "accessTokenSpecialUri");
final ResourceConfig resourceConfig = new ResourceConfig();
resourceConfig.register(oAuth1ServerFeature);
resourceConfig.register(MyProtectedResource.class);
resourceConfig.register(new LoggingFeature(Logger.getLogger(OAuthClientServerTest.class.getName()), LoggingFeature.Verbosity.PAYLOAD_ANY));
resourceConfig.register(OAuthAuthorizationResource.class);
resourceConfig.property(OAuth1ServerProperties.TIMESTAMP_UNIT, "SECONDS");
resourceConfig.property(OAuth1ServerProperties.MAX_NONCE_CACHE_SIZE, 20);
return resourceConfig;
}
Aggregations