Package org.apache.catalina.connector

Examples of org.apache.catalina.connector.Connector


    }

    public Connector createConnector(String address, int port,
            String protocol) {

        Connector connector = null;

        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);
            }
        }

        if (log.isDebugEnabled()) {
            log.debug("Creating connector for address='" +
                      ((address == null) ? "ALL" : address) +
                      "' port='" + port + "' protocol='" + protocol + "'");
        }

        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);
View Full Code Here


                container.addEngine( engine );

                getLog().debug( "start tomcat instance on http port:" + port + " and protocol: " + protocol );

                // create http connector
                Connector httpConnector = container.createConnector( (InetAddress) null, port, protocol );
                if ( httpsPort > 0 )
                {
                    httpConnector.setRedirectPort( httpsPort );
                }
                httpConnector.setURIEncoding( uriEncoding );
                container.addConnector( httpConnector );

                // create https connector
                if ( httpsPort > 0 )
                {
                    Connector httpsConnector = container.createConnector( (InetAddress) null, httpsPort, true );
                    httpsConnector.setSecure( true );
                    httpsConnector.setProperty( "SSLEnabled", "true" );
                    // should be default but configure it anyway
                    httpsConnector.setProperty( "sslProtocol", "TLS" );
                    if ( keystoreFile != null )
                    {
                        httpsConnector.setAttribute( "keystoreFile", keystoreFile );
                    }
                    if ( keystorePass != null )
                    {
                        httpsConnector.setAttribute( "keystorePass", keystorePass );
                    }
                    if ( keystoreType != null )
                    {
                        httpsConnector.setAttribute( "keystoreType", keystoreType );
                    }
                    container.addConnector( httpsConnector );

                }

                // create ajp connector
                if ( ajpPort > 0 )
                {
                    Connector ajpConnector = container.createConnector( (InetAddress) null, ajpPort, ajpProtocol );
                    ajpConnector.setURIEncoding( uriEncoding );
                    container.addConnector( ajpConnector );
                }
                if ( useSeparateTomcatClassLoader )
                {
                    Thread.currentThread().setContextClassLoader( getTomcatClassLoader() );
View Full Code Here

            debugMessage( "use connectorHttpProtocol:" + connectorHttpProtocol );

            if ( httpPort > 0 )
            {
                Connector connector = new Connector( connectorHttpProtocol );
                connector.setPort( httpPort );

                if ( httpsPort > 0 )
                {
                    connector.setRedirectPort( httpsPort );
                }
                connector.setURIEncoding( uriEncoding );

                tomcat.getService().addConnector( connector );

                tomcat.setConnector( connector );
            }

            // add a default acces log valve
            AccessLogValve alv = new AccessLogValve();
            alv.setDirectory( new File( extractDirectory, "logs" ).getAbsolutePath() );
            alv.setPattern( runtimeProperties.getProperty( Tomcat7Runner.ACCESS_LOG_VALVE_FORMAT_KEY ) );
            tomcat.getHost().getPipeline().addValve( alv );

            // create https connector
            if ( httpsPort > 0 )
            {
                Connector httpsConnector = new Connector( connectorHttpProtocol );
                httpsConnector.setPort( httpsPort );
                httpsConnector.setSecure( true );
                httpsConnector.setProperty( "SSLEnabled", "true" );
                httpsConnector.setProperty( "sslProtocol", "TLS" );
                httpsConnector.setURIEncoding( uriEncoding );

                String keystoreFile = System.getProperty( "javax.net.ssl.keyStore" );
                String keystorePass = System.getProperty( "javax.net.ssl.keyStorePassword" );
                String keystoreType = System.getProperty( "javax.net.ssl.keyStoreType", "jks" );

                if ( keystoreFile != null )
                {
                    httpsConnector.setAttribute( "keystoreFile", keystoreFile );
                }
                if ( keystorePass != null )
                {
                    httpsConnector.setAttribute( "keystorePass", keystorePass );
                }
                httpsConnector.setAttribute( "keystoreType", keystoreType );

                String truststoreFile = System.getProperty( "javax.net.ssl.trustStore" );
                String truststorePass = System.getProperty( "javax.net.ssl.trustStorePassword" );
                String truststoreType = System.getProperty( "javax.net.ssl.trustStoreType", "jks" );
                if ( truststoreFile != null )
                {
                    httpsConnector.setAttribute( "truststoreFile", truststoreFile );
                }
                if ( truststorePass != null )
                {
                    httpsConnector.setAttribute( "truststorePass", truststorePass );
                }
                httpsConnector.setAttribute( "truststoreType", truststoreType );

                httpsConnector.setAttribute( "clientAuth", clientAuth );
                httpsConnector.setAttribute( "keyAlias", keyAlias );

                tomcat.getService().addConnector( httpsConnector );

                if ( httpPort <= 0 )
                {
                    tomcat.setConnector( httpsConnector );
                }
            }

            // create ajp connector
            if ( ajpPort > 0 )
            {
                Connector ajpConnector = new Connector( "org.apache.coyote.ajp.AjpProtocol" );
                ajpConnector.setPort( ajpPort );
                ajpConnector.setURIEncoding( uriEncoding );
                tomcat.getService().addConnector( ajpConnector );
            }

            // add webapps
            for ( Map.Entry<String, String> entry : this.webappWarPerContext.entrySet() )
View Full Code Here

                    }

                }
                createStaticContext( embeddedTomcat, ctx, embeddedTomcat.getHost() );

                Connector connector = new Connector( protocol );
                connector.setPort( port );

                if ( httpsPort > 0 )
                {
                    connector.setRedirectPort( httpsPort );
                }

                connector.setURIEncoding( uriEncoding );

                embeddedTomcat.getService().addConnector( connector );

                embeddedTomcat.setConnector( connector );

                AccessLogValve alv = new AccessLogValve();
                alv.setDirectory( new File( configurationDir, "logs" ).getAbsolutePath() );
                alv.setPattern( "%h %l %u %t \"%r\" %s %b %I %D" );
                embeddedTomcat.getHost().getPipeline().addValve( alv );

                // create https connector
                Connector httpsConnector = null;
                if ( httpsPort > 0 )
                {
                    httpsConnector = new Connector( protocol );
                    httpsConnector.setPort( httpsPort );
                    httpsConnector.setSecure( true );
                    httpsConnector.setProperty( "SSLEnabled", "true" );
                    // should be default but configure it anyway
                    httpsConnector.setProperty( "sslProtocol", "TLS" );
                    if ( keystoreFile != null )
                    {
                        httpsConnector.setAttribute( "keystoreFile", keystoreFile );
                    }
                    if ( keystorePass != null )
                    {
                        httpsConnector.setAttribute( "keystorePass", keystorePass );
                    }
                    if ( keystoreType != null )
                    {
                        httpsConnector.setAttribute( "keystoreType", keystoreType );
                    }

                    httpsConnector.setAttribute( "clientAuth", clientAuth );

                    embeddedTomcat.getEngine().getService().addConnector( httpsConnector );

                }

                // create ajp connector
                Connector ajpConnector = null;
                if ( ajpPort > 0 )
                {
                    ajpConnector = new Connector( ajpProtocol );
                    ajpConnector.setPort( ajpPort );
                    ajpConnector.setURIEncoding( uriEncoding );
                    embeddedTomcat.getEngine().getService().addConnector( ajpConnector );
                }

                if ( addContextWarDependencies || !getAdditionalWebapps().isEmpty() )
                {
                    createDependencyContexts( embeddedTomcat );
                }

                if ( useSeparateTomcatClassLoader )
                {
                    Thread.currentThread().setContextClassLoader( getTomcatClassLoader() );
                    embeddedTomcat.getEngine().setParentClassLoader( getTomcatClassLoader() );
                }

                embeddedTomcat.start();

                Properties portProperties = new Properties();

                portProperties.put( "tomcat.maven.http.port", Integer.toString( connector.getLocalPort() ) );

                session.getExecutionProperties().put( "tomcat.maven.http.port",
                                                      Integer.toString( connector.getLocalPort() ) );
                System.setProperty( "tomcat.maven.http.port", Integer.toString( connector.getLocalPort() ) );

                if ( httpsConnector != null )
                {
                    session.getExecutionProperties().put( "tomcat.maven.https.port",
                                                          Integer.toString( httpsConnector.getLocalPort() ) );
                    portProperties.put( "tomcat.maven.https.port", Integer.toString( httpsConnector.getLocalPort() ) );
                    System.setProperty( "tomcat.maven.https.port", Integer.toString( httpsConnector.getLocalPort() ) );
                }

                if ( ajpConnector != null )
                {
                    session.getExecutionProperties().put( "tomcat.maven.ajp.port",
                                                          Integer.toString( ajpConnector.getLocalPort() ) );
                    portProperties.put( "tomcat.maven.ajp.port", Integer.toString( ajpConnector.getLocalPort() ) );
                    System.setProperty( "tomcat.maven.ajp.port", Integer.toString( ajpConnector.getLocalPort() ) );
                }
                if ( propertiesPortFilePath != null )
                {
                    File propertiesPortsFile = new File( propertiesPortFilePath );
                    if ( propertiesPortsFile.exists() )
View Full Code Here

            keyStore.setCertificateEntry("cert-alias", certificate);
            keyStore.setKeyEntry("key-alias", privateKey, keystorePass.toCharArray(), new Certificate[]{certificate});
            File keyStoreFile = new File("tcks");
            keyStore.store(new FileOutputStream(keyStoreFile), keystorePass.toCharArray());

            Connector sslConnector = new Connector();
            sslConnector.setPort(sslPort);
            sslConnector.setSecure(true);
            sslConnector.setScheme("https");
            sslConnector.setAttribute("keystoreFile", keyStoreFile.getAbsolutePath());
            sslConnector.setAttribute("keystorePass", keystorePass);
            sslConnector.setAttribute("clientAuth", "false");
            sslConnector.setAttribute("sslProtocol", "TLS");
            sslConnector.setAttribute("SSLEnabled", true);
            tomcat.getService().addConnector(sslConnector);
        }
    }
View Full Code Here

        // Create the Connector object
        if (conn == null) {

            //create a connector in connector management portlet will reach here.
            this.connector = new Connector(tomcatProtocol);
            for (LifecycleListener listener : TomcatServerGBean.LifecycleListeners) {
                this.connector.addLifecycleListener(listener);
            }
            wrappedConnector = false;
        } else if (conn.getState().equals(LifecycleState.DESTROYED)) {

            //restarting a connector in connector management portlet will reach here.
            this.connector = new Connector(tomcatProtocol);
            for (LifecycleListener listener : TomcatServerGBean.LifecycleListeners) {
                this.connector.addLifecycleListener(listener);
            }
        } else {
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

            Executor executor = executorType.getExecutor(cl, kernel);
            service.addExecutor(executor);
            TomcatServerGBean.executors.put(executor.getName(), executor);
        }
        for (ConnectorType connectorType: getConnector()) {
            Connector connector = connectorType.getConnector(cl, service);
            service.addConnector(connector);
        }
        for (ListenerType listenerType : getListener()) {
            LifecycleListener listener = listenerType.getLifecycleListener(cl);
            service.addLifecycleListener(listener);
View Full Code Here

        }
        ObjectRecipe recipe = new ObjectRecipe(className, properties);
        recipe.allow(Option.IGNORE_MISSING_PROPERTIES);
        recipe.setConstructorArgTypes(new Class[] { String.class });
        recipe.setConstructorArgNames(new String[] { "protocol" });
        Connector connector = (Connector) recipe.create(cl);
        boolean executorSupported = !connector.getProtocolHandlerClassName().equals("org.apache.jk.server.JkCoyoteHandler");
        for (Map.Entry<QName, String> entry : otherAttributes.entrySet()) {
            String name = entry.getKey().getLocalPart();
            String value = entry.getValue();
            if (executorSupported && "executor".equals(name)) {
                Executor executor = service.getExecutor(entry.getValue());
                if (executor == null) {
                    throw new IllegalArgumentException("No executor found in service with name: " + value);
                }
                IntrospectionUtils.callMethod1(connector.getProtocolHandler(),
                        "setExecutor",
                        executor,
                        java.util.concurrent.Executor.class.getName(),
                        cl);

            } else if ("name".equals(name)) {
                //name attribute is held by Geronimo to identify the connector, it is not required by Tomcat
                TomcatServerGBean.ConnectorName.put(connector, value);
            } else {
                if ("keystorePass".equals(name)) {
                    value = (String) EncryptionManager.decrypt(value);
                }
                connector.setProperty(name, value);
            }
        }

        for (ListenerType listenerType : getListener()) {
            LifecycleListener listener = listenerType.getLifecycleListener(cl);
            connector.addLifecycleListener(listener);
            TomcatServerGBean.LifecycleListeners.add(listener);
        }
        return connector;
    }
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(TapestryRunnerConstants.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

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.