Search in sources :

Example 31 with Connector

use of org.apache.catalina.connector.Connector in project meecrowave by apache.

the class Meecrowave method createConnector.

protected Connector createConnector() {
    final Connector connector;
    final Properties properties = configuration.properties;
    if (properties != null) {
        final Map<String, String> attributes = new HashMap<>();
        final ObjectRecipe recipe = new ObjectRecipe(Connector.class);
        for (final String key : properties.stringPropertyNames()) {
            if (!key.startsWith("connector.")) {
                continue;
            }
            final String substring = key.substring("connector.".length());
            if (substring.startsWith("sslhostconfig.")) {
                continue;
            }
            if (!substring.startsWith("attributes.")) {
                recipe.setProperty(substring, properties.getProperty(key));
            } else {
                attributes.put(substring.substring("attributes.".length()), properties.getProperty(key));
            }
        }
        connector = recipe.getProperties().isEmpty() ? new Connector() : Connector.class.cast(recipe.create());
        for (final Map.Entry<String, String> attr : attributes.entrySet()) {
            connector.setAttribute(attr.getKey(), attr.getValue());
        }
    } else {
        connector = new Connector();
    }
    return connector;
}
Also used : Connector(org.apache.catalina.connector.Connector) ObjectRecipe(org.apache.xbean.recipe.ObjectRecipe) HashMap(java.util.HashMap) Properties(java.util.Properties) Map(java.util.Map) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap)

Example 32 with Connector

use of org.apache.catalina.connector.Connector in project cas by apereo.

the class CasEmbeddedContainerTomcatConfiguration method configureHttp.

private void configureHttp(final TomcatEmbeddedServletContainerFactory tomcat) {
    final CasEmbeddedApacheTomcatHttpProperties http = casProperties.getServer().getHttp();
    if (http.isEnabled()) {
        LOGGER.debug("Creating HTTP configuration for the embedded tomcat container...");
        final Connector connector = new Connector(http.getProtocol());
        int port = http.getPort();
        if (port <= 0) {
            LOGGER.warn("No explicit port configuration is provided to CAS. Scanning for available ports...");
            port = SocketUtils.findAvailableTcpPort();
        }
        LOGGER.info("Activated embedded tomcat container HTTP port on [{}]", port);
        connector.setPort(port);
        LOGGER.debug("Configuring embedded tomcat container for HTTP2 protocol support");
        connector.addUpgradeProtocol(new Http2Protocol());
        http.getAttributes().forEach(connector::setAttribute);
        tomcat.addAdditionalTomcatConnectors(connector);
    }
}
Also used : CasEmbeddedApacheTomcatHttpProperties(org.apereo.cas.configuration.model.core.web.tomcat.CasEmbeddedApacheTomcatHttpProperties) Connector(org.apache.catalina.connector.Connector) SecurityConstraint(org.apache.tomcat.util.descriptor.web.SecurityConstraint) Http2Protocol(org.apache.coyote.http2.Http2Protocol)

Example 33 with Connector

use of org.apache.catalina.connector.Connector in project cas by apereo.

the class CasEmbeddedContainerTomcatConfiguration method configureAjp.

private void configureAjp(final TomcatEmbeddedServletContainerFactory tomcat) {
    final CasEmbeddedApacheTomcatAjpProperties ajp = casProperties.getServer().getAjp();
    if (ajp.isEnabled() && ajp.getPort() > 0) {
        LOGGER.debug("Creating AJP configuration for the embedded tomcat container...");
        final Connector ajpConnector = new Connector(ajp.getProtocol());
        ajpConnector.setProtocol(ajp.getProtocol());
        ajpConnector.setPort(ajp.getPort());
        ajpConnector.setSecure(ajp.isSecure());
        ajpConnector.setAllowTrace(ajp.isAllowTrace());
        ajpConnector.setScheme(ajp.getScheme());
        ajpConnector.setAsyncTimeout(Beans.newDuration(ajp.getAsyncTimeout()).toMillis());
        ajpConnector.setEnableLookups(ajp.isEnableLookups());
        ajpConnector.setMaxPostSize(ajp.getMaxPostSize());
        ajpConnector.addUpgradeProtocol(new Http2Protocol());
        if (ajp.getProxyPort() > 0) {
            LOGGER.debug("Set AJP proxy port to [{}]", ajp.getProxyPort());
            ajpConnector.setProxyPort(ajp.getProxyPort());
        }
        if (ajp.getRedirectPort() > 0) {
            LOGGER.debug("Set AJP redirect port to [{}]", ajp.getRedirectPort());
            ajpConnector.setRedirectPort(ajp.getRedirectPort());
        }
        ajp.getAttributes().forEach(ajpConnector::setAttribute);
        tomcat.addAdditionalTomcatConnectors(ajpConnector);
    }
}
Also used : Connector(org.apache.catalina.connector.Connector) CasEmbeddedApacheTomcatAjpProperties(org.apereo.cas.configuration.model.core.web.tomcat.CasEmbeddedApacheTomcatAjpProperties) Http2Protocol(org.apache.coyote.http2.Http2Protocol)

Example 34 with Connector

use of org.apache.catalina.connector.Connector in project Payara by payara.

the class PwcCoyoteRequest method getPostDataEncoding.

private String getPostDataEncoding(String formHintField) {
    if (!getMethod().equalsIgnoreCase("POST")) {
        return null;
    }
    String contentType = getContentType();
    if (contentType == null)
        contentType = "";
    int semicolon = contentType.indexOf(';');
    if (semicolon >= 0) {
        contentType = contentType.substring(0, semicolon).trim();
    } else {
        contentType = contentType.trim();
    }
    if (!("application/x-www-form-urlencoded".equals(contentType))) {
        return null;
    }
    int len = getContentLength();
    if (len <= 0) {
        return null;
    }
    int maxPostSize = ((Connector) connector).getMaxPostSize();
    if ((maxPostSize > 0) && (len > maxPostSize)) {
        throw new IllegalStateException(rb.getString(LogFacade.POST_TOO_LARGE));
    }
    String encoding = null;
    try {
        formData = null;
        if (len < CACHED_POST_LEN) {
            if (postData == null)
                postData = new byte[CACHED_POST_LEN];
            formData = postData;
        } else {
            formData = new byte[len];
        }
        int actualLen = readPostBody(formData, len);
        if (actualLen == len) {
            // START SJSAS 6346738
            formDataLen = actualLen;
            // END SJSAS 6346738
            String formDataString = new String(formData, Charset.defaultCharset()).substring(0, len);
            encoding = parseFormHintField(formDataString, formHintField);
        }
    } catch (Throwable t) {
        // Ignore
        ;
    }
    return encoding;
}
Also used : Connector(org.apache.catalina.connector.Connector) String(java.lang.String)

Example 35 with Connector

use of org.apache.catalina.connector.Connector in project tomee by apache.

the class Container method stop.

public void stop() throws Exception {
    final Connector connector = tomcat.getConnector();
    if (null != connector) {
        connector.stop();
    }
    try {
        tomcat.stop();
    } catch (final LifecycleException e) {
        e.printStackTrace();
    }
    try {
        tomcat.destroy();
    } catch (final LifecycleException e) {
        e.printStackTrace();
    }
    if (configuration.isDeleteBaseOnStartup()) {
        try {
            deleteTree(base);
        } catch (final Exception e) {
            e.printStackTrace();
        }
    }
    OpenEJB.destroy();
// don't set base = null here to be able to use base after to clean up from outside of this class
}
Also used : Connector(org.apache.catalina.connector.Connector) LifecycleException(org.apache.catalina.LifecycleException) LifecycleException(org.apache.catalina.LifecycleException) IOException(java.io.IOException) TomEERuntimeException(org.apache.tomee.catalina.TomEERuntimeException) NamingException(javax.naming.NamingException) UndeployException(org.apache.openejb.UndeployException) OpenEJBException(org.apache.openejb.OpenEJBException) NoSuchApplicationException(org.apache.openejb.NoSuchApplicationException) MalformedURLException(java.net.MalformedURLException)

Aggregations

Connector (org.apache.catalina.connector.Connector)70 Test (org.junit.Test)16 Service (org.apache.catalina.Service)15 File (java.io.File)12 Tomcat (org.apache.catalina.startup.Tomcat)11 Properties (java.util.Properties)8 Context (org.apache.catalina.Context)7 HashMap (java.util.HashMap)6 Engine (org.apache.catalina.Engine)6 SSLHostConfig (org.apache.tomcat.util.net.SSLHostConfig)6 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 Map (java.util.Map)5 StandardService (org.apache.catalina.core.StandardService)5 URI (java.net.URI)4 Executor (org.apache.catalina.Executor)4 LifecycleException (org.apache.catalina.LifecycleException)4 Server (org.apache.catalina.Server)4 Http2Protocol (org.apache.coyote.http2.Http2Protocol)4 ObjectName (javax.management.ObjectName)3