Search in sources :

Example 1 with Router

use of com.predic8.membrane.core.Router in project service-proxy by membrane.

the class JavascriptInterceptor method init.

@Override
public void init() throws IOException, ClassNotFoundException {
    if (router == null)
        return;
    if ("".equals(src))
        return;
    jls = new JavascriptLanguageSupport();
    implicitClasses = getJavascriptTypesForHttpClasses();
    script = jls.compileScript(router, src);
}
Also used : JavascriptLanguageSupport(com.predic8.membrane.core.lang.javascript.JavascriptLanguageSupport)

Example 2 with Router

use of com.predic8.membrane.core.Router in project service-proxy by membrane.

the class OAuth2AuthorizationServerInterceptor method init.

@Override
public void init(Router router) throws Exception {
    name = "OAuth 2 Authorization Server";
    setFlow(Flow.Set.REQUEST_RESPONSE);
    this.setRouter(router);
    addSupportedAuthorizationGrants();
    getWellknownFile().init(router, this);
    getConsentPageFile().init(router, getConsentFile());
    if (userDataProvider == null)
        throw new Exception("No userDataProvider configured. - Cannot work without one.");
    if (getClientList() == null)
        throw new Exception("No clientList configured. - Cannot work without one.");
    if (getClaimList() == null)
        throw new Exception("No scopeList configured. - Cannot work without one");
    if (getLocation() == null) {
        log.warn("===========================================================================================");
        log.warn("IMPORTANT: No location configured - Authorization code and implicit flows are not available");
        log.warn("===========================================================================================");
        loginViewDisabled = true;
    }
    if (getConsentFile() == null && !isLoginViewDisabled()) {
        log.warn("==============================================================================================");
        log.warn("IMPORTANT: No consentFile configured - Authorization code and implicit flows are not available");
        log.warn("==============================================================================================");
        loginViewDisabled = true;
    }
    if (getPath() == null)
        throw new Exception("No path configured. - Cannot work without one");
    userDataProvider.init(router);
    getClientList().init(router);
    getClaimList().init(router);
    jwtGenerator = new JwtGenerator();
    sessionManager.init(router);
    statistics = new OAuth2Statistics();
    addDefaultProcessors();
    new CleanupThread(sessionManager, accountBlocker).start();
}
Also used : JwtGenerator(com.predic8.membrane.core.interceptor.oauth2.tokengenerators.JwtGenerator) CleanupThread(com.predic8.membrane.core.interceptor.authentication.session.CleanupThread)

Example 3 with Router

use of com.predic8.membrane.core.Router 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 4 with Router

use of com.predic8.membrane.core.Router in project service-proxy by membrane.

the class ValidatorInterceptor method init.

@Override
public void init() throws Exception {
    validator = null;
    String baseLocation = router == null ? null : router.getBaseLocation();
    if (wsdl != null) {
        name = "SOAP Validator";
        setValidator(new WSDLValidator(resourceResolver, ResolverMap.combine(baseLocation, wsdl), createFailureHandler(), skipFaults));
    }
    if (schema != null) {
        name = "XML Schema Validator";
        setValidator(new XMLSchemaValidator(resourceResolver, ResolverMap.combine(baseLocation, schema), createFailureHandler()));
    }
    if (jsonSchema != null) {
        name = "JSON Schema Validator";
        setValidator(new JSONValidator(resourceResolver, ResolverMap.combine(baseLocation, jsonSchema), createFailureHandler()));
    }
    if (schematron != null) {
        name = "Schematron Validator";
        setValidator(new SchematronValidator(resourceResolver, ResolverMap.combine(baseLocation, schematron), createFailureHandler(), router, applicationContext));
    }
    if (validator == null) {
        Rule parent = router.getParentProxy(this);
        if (parent instanceof SOAPProxy) {
            wsdl = ((SOAPProxy) parent).getWsdl();
            name = "SOAP Validator";
            setValidator(new WSDLValidator(resourceResolver, ResolverMap.combine(baseLocation, wsdl), createFailureHandler(), skipFaults));
        }
        if (validator == null)
            throw new Exception("<validator> must have an attribute specifying the validator.");
    }
    if (skipFaults && wsdl == null)
        throw new Exception("validator/@skipFaults only makes sense with validator/@wsdl");
}
Also used : SOAPProxy(com.predic8.membrane.core.rules.SOAPProxy) Rule(com.predic8.membrane.core.rules.Rule) BeansException(org.springframework.beans.BeansException)

Example 5 with Router

use of com.predic8.membrane.core.Router in project service-proxy by membrane.

the class LargeBodyTest method setup.

public void setup() throws Exception {
    // streaming only works for maxRetries = 1
    hcc = new HttpClientConfiguration();
    hcc.setMaxRetries(1);
    Rule rule = new ServiceProxy(new ServiceProxyKey("localhost", "POST", ".*", 3040), "thomas-bayer.com", 80);
    rule.getInterceptors().add(new AbstractInterceptor() {

        @Override
        public Outcome handleRequest(Exchange exc) throws Exception {
            exc.setResponse(Response.ok().body("").build());
            return Outcome.RETURN;
        }
    });
    router = new HttpRouter();
    ((HTTPClientInterceptor) router.getTransport().getInterceptors().get(3)).setHttpClientConfig(hcc);
    router.getRuleManager().addProxyAndOpenPortIfNew(rule);
    router.init();
    Rule rule1 = new ServiceProxy(new ServiceProxyKey("localhost", "POST", ".*", 3041), "localhost", 3040);
    router2 = new HttpRouter();
    ((HTTPClientInterceptor) router2.getTransport().getInterceptors().get(3)).setHttpClientConfig(hcc);
    router2.getRuleManager().addProxyAndOpenPortIfNew(rule1);
    router2.init();
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange) ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) HTTPClientInterceptor(com.predic8.membrane.core.interceptor.HTTPClientInterceptor) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) Outcome(com.predic8.membrane.core.interceptor.Outcome) AbstractInterceptor(com.predic8.membrane.core.interceptor.AbstractInterceptor) Rule(com.predic8.membrane.core.rules.Rule) HttpRouter(com.predic8.membrane.core.HttpRouter) HttpClientConfiguration(com.predic8.membrane.core.transport.http.client.HttpClientConfiguration) IOException(java.io.IOException)

Aggregations

HttpRouter (com.predic8.membrane.core.HttpRouter)24 ServiceProxy (com.predic8.membrane.core.rules.ServiceProxy)21 ServiceProxyKey (com.predic8.membrane.core.rules.ServiceProxyKey)19 Before (org.junit.Before)18 Rule (com.predic8.membrane.core.rules.Rule)16 IOException (java.io.IOException)9 Router (com.predic8.membrane.core.Router)8 Exchange (com.predic8.membrane.core.exchange.Exchange)6 AbstractInterceptor (com.predic8.membrane.core.interceptor.AbstractInterceptor)5 Outcome (com.predic8.membrane.core.interceptor.Outcome)5 ProxyRule (com.predic8.membrane.core.rules.ProxyRule)5 StringWriter (java.io.StringWriter)5 Test (org.junit.Test)5 Interceptor (com.predic8.membrane.core.interceptor.Interceptor)3 Node (com.predic8.membrane.core.interceptor.balancer.Node)3 Mapping (com.predic8.membrane.core.interceptor.rewrite.RewriteInterceptor.Mapping)3 AbstractServiceProxy (com.predic8.membrane.core.rules.AbstractServiceProxy)3 ProxyRuleKey (com.predic8.membrane.core.rules.ProxyRuleKey)3 HttpClientConfiguration (com.predic8.membrane.core.transport.http.client.HttpClientConfiguration)3 File (java.io.File)3