Package org.apache.catalina.connector

Examples of org.apache.catalina.connector.Connector


   public void setNewSessionCookie(String sessionId, HttpServletResponse response)
   {
      if (response != null)
      {
         Context context = (Context) container_;
         Connector connector = ((Response) response).getConnector();
         if (context.getCookies())
         {
            // set a new session cookie
            TomcatCookie cookie = new TomcatCookie(Globals.SESSION_COOKIE_NAME, sessionId);
            // JBAS-6206. Configure cookie a la o.a.c.connector.Request.configureSessionCookie()
            cookie.setMaxAge(-1);
            if (context.getSessionCookie().getPath() != null)
            {
               cookie.setPath(context.getSessionCookie().getPath());
            }
            else
            {
               String contextPath = context.getEncodedPath();
               if ("".equals(contextPath))
               {
                  contextPath = "/";
               }
               cookie.setPath(contextPath);
            }
            if (context.getSessionCookie().getComment() != null)
            {
               cookie.setComment(context.getSessionCookie().getComment());
            }
            if (context.getSessionCookie().getDomain() != null)
            {
               cookie.setDomain(context.getSessionCookie().getDomain());
            }
            if (context.getSessionCookie().isHttpOnly())
            {
               cookie.setHttpOnly(true);
            }
            if (context.getSessionCookie().isSecure())
            {
               cookie.setSecure(true);
            }
            if (connector.getSecure())
            {
               cookie.setSecure(true);
            }

            if (trace_)
View Full Code Here


        host.addChild(context);

        tomcatServer.addEngine(engine);

        Connector http = tomcatServer.createConnector("localhost", port, false);
        http.setAllowTrace(true);
        tomcatServer.addConnector(http);

        // SSL support
        final File keystoreFile = new File(TapestryTestConstants.MODULE_BASE_DIR, "src/test/conf/keystore");

        if (keystoreFile.exists())
        {
            final Connector https = tomcatServer.createConnector("localhost", sslPort, true);
            https.setProperty("keystore", keystoreFile.getPath());
            https.setProperty("keypass", "tapestry");
            tomcatServer.addConnector(https);
        }

        tomcatServer.start();
    }
View Full Code Here

    }

    @Test
    public void testStartStopBindOnStart() throws Exception {
        Tomcat tomcat = getTomcatInstance();
        Connector c = tomcat.getConnector();
        c.setProperty("bindOnInit", "false");
       
        File appDir = new File(getBuildDirectory(), "webapps/examples");
        tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
       
        int port = getPort();
View Full Code Here

    public void testCustomSslImplementation() throws Exception {

        TesterSupport.configureClientSsl();

        Tomcat tomcat = getTomcatInstance();
        Connector connector = tomcat.getConnector();
        if (connector.getProtocolHandlerClassName().contains("Apr")) {
            // This test is only for JSSE based SSL connectors
            return;
        }

        connector.setProperty("sslImplemenationName",
                "org.apache.tomcat.util.net.jsse.TesterBug50640SslImpl");
        connector.setProperty(TesterBug50640SslImpl.PROPERTY_NAME,
                TesterBug50640SslImpl.PROPERTY_VALUE);
       
        connector.setProperty("sslProtocol", "tls");
       
        File keystoreFile =
            new File("test/org/apache/tomcat/util/net/localhost.jks");
        connector.setAttribute(
                "keystoreFile", keystoreFile.getAbsolutePath());

        connector.setSecure(true);           
        connector.setProperty("SSLEnabled", "true");

        File appDir = new File(getBuildDirectory(), "webapps/examples");
        tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());

        tomcat.start();
View Full Code Here

    protected static void initSsl(Tomcat tomcat, String keystore,
            String keystorePass, String keyPass) {

        String protocol = tomcat.getConnector().getProtocolHandlerClassName();
        if (protocol.indexOf("Apr") == -1) {
            Connector connector = tomcat.getConnector();
            connector.setProperty("sslProtocol", "tls");
            File keystoreFile =
                new File("test/org/apache/tomcat/util/net/" + keystore);
            connector.setAttribute("keystoreFile",
                    keystoreFile.getAbsolutePath());
            File truststoreFile = new File(
                    "test/org/apache/tomcat/util/net/ca.jks");
            connector.setAttribute("truststoreFile",
                    truststoreFile.getAbsolutePath());
            if (keystorePass != null) {
                connector.setAttribute("keystorePass", keystorePass);
            }
            if (keyPass != null) {
                connector.setAttribute("keyPass", keyPass);
            }
        } else {
            File keystoreFile = new File(
                    "test/org/apache/tomcat/util/net/localhost-cert.pem");
            tomcat.getConnector().setAttribute("SSLCertificateFile",
View Full Code Here

            protocol = "https";
        } else {
            protocol = "http";
        }

        Connector connector = null;
        if (UtilValidate.isNotEmpty(connectorProp.properties)) {
            if (address != null) {
                /*
                 * InetAddress.toString() returns a string of the form
                 * "<hostname>/<literal_IP>". Get the latter part, so that the
                 * address can be parsed (back) into an InetAddress using
                 * InetAddress.getByName().
                 */
                int index = address.indexOf('/');
                if (index != -1) {
                    address = address.substring(index + 1);
                }
            }

            Debug.logInfo("Creating connector for address='" +
                          ((address == null) ? "ALL" : address) +
                          "' port='" + port + "' protocol='" + protocol + "'", module);

            try {

                if (protocol.equals("ajp")) {
                    connector = new Connector("org.apache.coyote.ajp.AjpProtocol");
                } else if (protocol.equals("memory")) {
                    connector = new Connector("org.apache.coyote.memory.MemoryProtocolHandler");
                } else if (protocol.equals("http")) {
                    connector = new Connector();
                } else if (protocol.equals("https")) {
                    connector = new Connector();
                    connector.setScheme("https");
                    connector.setSecure(true);
                    connector.setProperty("SSLEnabled","true");
                    // FIXME !!!! SET SSL PROPERTIES
                } else {
                    connector = new Connector(protocol);
                }

                if (address != null) {
                    IntrospectionUtils.setProperty(connector, "address", "" + address);
                }
                IntrospectionUtils.setProperty(connector, "port", "" + port);

            } catch (Exception e) {
                Debug.logError(e, "Couldn't create connector.", module);
            }

            try {
                for (ContainerConfig.Container.Property prop: connectorProp.properties.values()) {
                    connector.setProperty(prop.name, prop.value);
                    //connector.setAttribute(prop.name, prop.value);
                }

                if (connectorProp.properties.containsKey("URIEncoding")) {
                    connector.setURIEncoding(connectorProp.properties.get("URIEncoding").value);
                }

                tomcat.getService().addConnector(connector);
            } catch (Exception e) {
                throw new ContainerException(e);
View Full Code Here

            ContextConfig config = new ContextConfig();
            ((Lifecycle)context).addLifecycleListener(config);
            host.addChild(context);

            // Install an HTTP connector
            Connector connector;
            try {
                engine.start();
                connector = new CustomConnector();
                connector.setPort(portNumber);
                connector.setContainer(engine);
                connector.initialize();
                connector.start();
            } catch (Exception e) {
                throw new ServletMappingException(e);
            }

            // Keep track of the running server
View Full Code Here


    private boolean isNativeAPRLibInstalled() {

        try {
            Connector connector = new Connector("HTTP/1.1");
            if (!connector.getProtocolHandlerClassName().equalsIgnoreCase("org.apache.coyote.http11.Http11AprProtocol")) {       
               return false;
            }
        } catch (Exception e) {
          
           return false;
View Full Code Here

    public void testCustomSslImplementation() throws Exception {

        TesterSupport.configureClientSsl();

        Tomcat tomcat = getTomcatInstance();
        Connector connector = tomcat.getConnector();

        Assume.assumeFalse("This test is only for JSSE based SSL connectors",
                connector.getProtocolHandlerClassName().contains("Apr"));

        connector.setProperty("sslImplementationName",
                "org.apache.tomcat.util.net.jsse.TesterBug50640SslImpl");
        connector.setProperty(TesterBug50640SslImpl.PROPERTY_NAME,
                TesterBug50640SslImpl.PROPERTY_VALUE);

        connector.setProperty("sslProtocol", "tls");

        File keystoreFile =
            new File("test/org/apache/tomcat/util/net/localhost.jks");
        connector.setAttribute(
                "keystoreFile", keystoreFile.getAbsolutePath());

        connector.setSecure(true);
        connector.setProperty("SSLEnabled", "true");

        File appDir = new File(getBuildDirectory(), "webapps/examples");
        tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());

        tomcat.start();
View Full Code Here

        // This will load Apr connector if available,
        // default to nio. I'm having strange problems with apr
        // XXX: jfclere weird... Don't add the AprLifecycleListener then.
        // and for the use case the speed benefit wouldn't matter.
       
        connector = new Connector("HTTP/1.1");
        // connector = new Connector("org.apache.coyote.http11.Http11Protocol");
        connector.setPort(port);
        service.addConnector( connector );
        return connector;
    }
View Full Code Here

TOP

Related Classes of org.apache.catalina.connector.Connector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.