Search in sources :

Example 1 with OAuth1ServerFeature

use of org.glassfish.jersey.server.oauth1.OAuth1ServerFeature 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;
}
Also used : LoggingFeature(org.glassfish.jersey.logging.LoggingFeature) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) DefaultOAuth1Provider(org.glassfish.jersey.server.oauth1.DefaultOAuth1Provider) OAuth1ServerFeature(org.glassfish.jersey.server.oauth1.OAuth1ServerFeature) UserPrincipal(com.sun.security.auth.UserPrincipal) Principal(java.security.Principal)

Aggregations

UserPrincipal (com.sun.security.auth.UserPrincipal)1 Principal (java.security.Principal)1 LoggingFeature (org.glassfish.jersey.logging.LoggingFeature)1 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)1 DefaultOAuth1Provider (org.glassfish.jersey.server.oauth1.DefaultOAuth1Provider)1 OAuth1ServerFeature (org.glassfish.jersey.server.oauth1.OAuth1ServerFeature)1