Search in sources :

Example 1 with WebServerInterceptor

use of com.predic8.membrane.core.interceptor.server.WebServerInterceptor in project service-proxy by membrane.

the class OAuth2ResourceInterceptor method init.

@Override
public void init(Router router) throws Exception {
    name = "OAuth 2 Client";
    setFlow(Flow.Set.REQUEST_RESPONSE);
    super.init(router);
    auth.init(router);
    statistics = new OAuth2Statistics();
    uriFactory = router.getUriFactory();
    if (sessionManager == null)
        sessionManager = new SessionManager();
    // TODO maybe do this differently as now the attribute in the bean is overwritten ( when set from external proxies.xml )
    sessionManager.setCookieName("SESSION_ID_CLIENT");
    sessionManager.init(router);
    if (loginLocation != null) {
        wsi = new WebServerInterceptor();
        wsi.setDocBase(loginLocation);
        router.getResolverMap().resolve(ResolverMap.combine(router.getBaseLocation(), wsi.getDocBase(), "./index.html")).close();
        wsi.init(router);
    }
    if (publicURL == null)
        initPublicURLOnFirstExchange = true;
    else
        normalizePublicURL();
    firstInitWhenDynamicAuthorizationService = getAuthService().supportsDynamicRegistration();
    if (!getAuthService().supportsDynamicRegistration())
        firstInitWhenDynamicAuthorizationService = false;
    new CleanupThread(sessionManager).start();
}
Also used : CleanupThread(com.predic8.membrane.core.interceptor.authentication.session.CleanupThread) SessionManager(com.predic8.membrane.core.interceptor.authentication.session.SessionManager) WebServerInterceptor(com.predic8.membrane.core.interceptor.server.WebServerInterceptor)

Example 2 with WebServerInterceptor

use of com.predic8.membrane.core.interceptor.server.WebServerInterceptor in project service-proxy by membrane.

the class ResolverTest method setup.

@BeforeClass
public static void setup() throws Exception {
    ServiceProxy sp = new ServiceProxy(new ServiceProxyKey(3029), "localhost", 8080);
    sp.getInterceptors().add(new AbstractInterceptor() {

        @Override
        public Outcome handleRequest(Exchange exc) throws Exception {
            hit = true;
            return Outcome.CONTINUE;
        }
    });
    WebServerInterceptor i = new WebServerInterceptor();
    if (deployment.equals(STANDALONE))
        i.setDocBase("src/test/resources");
    else {
        i.setDocBase("/test");
        router.getResolverMap().addSchemaResolver(resolverMap.getFileSchemaResolver());
    }
    sp.getInterceptors().add(i);
    router.add(sp);
    router.init();
}
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) WebServerInterceptor(com.predic8.membrane.core.interceptor.server.WebServerInterceptor) InvalidParameterException(java.security.InvalidParameterException) IOException(java.io.IOException) BeforeClass(org.junit.BeforeClass)

Example 3 with WebServerInterceptor

use of com.predic8.membrane.core.interceptor.server.WebServerInterceptor in project service-proxy by membrane.

the class LimitInterceptorTest method before.

@BeforeClass
public static void before() throws Exception {
    router = new HttpRouter();
    ServiceProxy sp2 = new ServiceProxy(new ServiceProxyKey("*", "*", ".*", 3026), "", -1);
    LimitInterceptor wi = new LimitInterceptor();
    wi.setMaxBodyLength(10);
    wi.setFlow(Flow.Set.REQUEST);
    sp2.getInterceptors().add(wi);
    WebServerInterceptor wi2 = new WebServerInterceptor();
    wi2.setDocBase("classpath:");
    wi2.init();
    sp2.getInterceptors().add(wi2);
    router.getRuleManager().addProxyAndOpenPortIfNew(sp2);
    router.init();
}
Also used : ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) WebServerInterceptor(com.predic8.membrane.core.interceptor.server.WebServerInterceptor) HttpRouter(com.predic8.membrane.core.HttpRouter)

Aggregations

WebServerInterceptor (com.predic8.membrane.core.interceptor.server.WebServerInterceptor)3 ServiceProxy (com.predic8.membrane.core.rules.ServiceProxy)2 ServiceProxyKey (com.predic8.membrane.core.rules.ServiceProxyKey)2 HttpRouter (com.predic8.membrane.core.HttpRouter)1 Exchange (com.predic8.membrane.core.exchange.Exchange)1 AbstractInterceptor (com.predic8.membrane.core.interceptor.AbstractInterceptor)1 Outcome (com.predic8.membrane.core.interceptor.Outcome)1 CleanupThread (com.predic8.membrane.core.interceptor.authentication.session.CleanupThread)1 SessionManager (com.predic8.membrane.core.interceptor.authentication.session.SessionManager)1 IOException (java.io.IOException)1 InvalidParameterException (java.security.InvalidParameterException)1 BeforeClass (org.junit.BeforeClass)1