Search in sources :

Example 1 with MembraneAuthorizationService

use of com.predic8.membrane.core.interceptor.oauth2.authorizationservice.MembraneAuthorizationService in project service-proxy by membrane.

the class OAuth2ResourceTest method getConfiguredOAuth2Resource.

private ServiceProxy getConfiguredOAuth2Resource() {
    ServiceProxy sp = new ServiceProxy(new ServiceProxyKey(clientPort), null, 99999);
    OAuth2ResourceInterceptor oAuth2ResourceInterceptor = new OAuth2ResourceInterceptor();
    MembraneAuthorizationService auth = new MembraneAuthorizationService();
    auth.setSrc(getServerAddress());
    auth.setClientId("2343243242");
    auth.setClientSecret("3423233123123");
    auth.setScope("openid profile");
    oAuth2ResourceInterceptor.setAuthService(auth);
    sp.getInterceptors().add(oAuth2ResourceInterceptor);
    sp.getInterceptors().add(new AbstractInterceptor() {

        @Override
        public Outcome handleRequest(Exchange exc) throws Exception {
            OAuth2AnswerParameters answer = OAuth2AnswerParameters.deserialize(String.valueOf(exc.getProperty(Exchange.OAUTH2)));
            exc.setResponse(Response.ok(answer.getAccessToken()).build());
            return Outcome.RETURN;
        }
    });
    return sp;
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange) ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) Outcome(com.predic8.membrane.core.interceptor.Outcome) AbstractInterceptor(com.predic8.membrane.core.interceptor.AbstractInterceptor) MembraneAuthorizationService(com.predic8.membrane.core.interceptor.oauth2.authorizationservice.MembraneAuthorizationService) IOException(java.io.IOException)

Example 2 with MembraneAuthorizationService

use of com.predic8.membrane.core.interceptor.oauth2.authorizationservice.MembraneAuthorizationService in project service-proxy by membrane.

the class OAuth2AuthorizationServerInterceptorBase method initMas.

private void initMas() throws Exception {
    mas = new MembraneAuthorizationService();
    mas.setClientId("abc");
    mas.setClientSecret("def");
    mas.setSrc(System.getProperty("user.dir") + "\\src\\test\\resources\\oauth2");
    mas.init(router);
}
Also used : MembraneAuthorizationService(com.predic8.membrane.core.interceptor.oauth2.authorizationservice.MembraneAuthorizationService)

Aggregations

MembraneAuthorizationService (com.predic8.membrane.core.interceptor.oauth2.authorizationservice.MembraneAuthorizationService)2 Exchange (com.predic8.membrane.core.exchange.Exchange)1 AbstractInterceptor (com.predic8.membrane.core.interceptor.AbstractInterceptor)1 Outcome (com.predic8.membrane.core.interceptor.Outcome)1 ServiceProxy (com.predic8.membrane.core.rules.ServiceProxy)1 ServiceProxyKey (com.predic8.membrane.core.rules.ServiceProxyKey)1 IOException (java.io.IOException)1