Package org.eclipse.jetty.server.ssl

Examples of org.eclipse.jetty.server.ssl.SslSelectChannelConnector


public class ExplicitHttpsRouteTest extends HttpsRouteTest {

    // START SNIPPET: e2
    private SslSelectChannelConnector createSslSocketConnector() throws URISyntaxException {
        // From Camel 2.5.0 Camel-Jetty is using SslSelectChannelConnector instead of SslSocketConnector
        SslSelectChannelConnector sslSocketConnector = new SslSelectChannelConnector();
        sslSocketConnector.getSslContextFactory().setKeyManagerPassword(pwd);
        sslSocketConnector.getSslContextFactory().setKeyStorePassword(pwd);
        URL keyStoreUrl = this.getClass().getClassLoader().getResource("jsse/localhost.ks");
        sslSocketConnector.getSslContextFactory().setKeyStorePath(keyStoreUrl.toURI().getPath());
        sslSocketConnector.getSslContextFactory().setTrustStoreType("JKS");
        return sslSocketConnector;
    }
View Full Code Here


        return servlet;
    }

    protected SslConnector getSslSocketConnector() {
        SslSelectChannelConnector sslSocketConnector = null;
        if (sslContextParameters != null) {
            SslContextFactory sslContextFactory = new CometdComponentSslContextFactory();
            try {
                sslContextFactory.setSslContext(sslContextParameters.createSSLContext());
            } catch (Exception e) {
                throw new RuntimeCamelException("Error initiating SSLContext.", e);
            }
            sslSocketConnector = new SslSelectChannelConnector(sslContextFactory);
        } else {

            sslSocketConnector = new SslSelectChannelConnector();
            // with default null values, jetty ssl system properties
            // and console will be read by jetty implementation
            sslSocketConnector.getSslContextFactory().setKeyManagerPassword(sslPassword);
            sslSocketConnector.getSslContextFactory().setKeyStorePassword(sslKeyPassword);
            if (sslKeystore != null) {
                sslSocketConnector.getSslContextFactory().setKeyStorePath(sslKeystore);
            }

        }

        return sslSocketConnector;
View Full Code Here

    public String getKeystore() {
        return sslKeystore;
    }

    protected SslSelectChannelConnector getSslSocketConnector(int port) throws Exception {
        SslSelectChannelConnector answer = null;
        if (sslSocketConnectors != null) {
            answer = sslSocketConnectors.get(port);
        }
        if (answer == null) {
            answer = createSslSocketConnector();
View Full Code Here

        }
        return answer;
    }
   
    protected SslSelectChannelConnector createSslSocketConnector() throws Exception {
        SslSelectChannelConnector answer = new SslSelectChannelConnector();
        // with default null values, jetty ssl system properties
        // and console will be read by jetty implementation

        String keystoreProperty = System.getProperty(JETTY_SSL_KEYSTORE);
        if (keystoreProperty != null) {
            answer.setKeystore(keystoreProperty);
        } else if (sslKeystore != null) {
            answer.setKeystore(sslKeystore);
        }

        String keystorePassword = System.getProperty(JETTY_SSL_KEYPASSWORD);
        if (keystorePassword != null) {
            answer.setKeyPassword(keystorePassword);
        } else if (sslKeyPassword != null) {
            answer.setKeyPassword(sslKeyPassword);
        }

        String password = System.getProperty(JETTY_SSL_PASSWORD);
        if (password != null) {
            answer.setPassword(password);
        } else if (sslPassword != null) {
            answer.setPassword(sslPassword);
        }

        if (getSslSocketConnectorProperties() != null) {
            // must copy the map otherwise it will be deleted
            Map<String, Object> properties = new HashMap<String, Object>(getSslSocketConnectorProperties());
View Full Code Here

        else if (_transport == Transport.WSS)
        {
            SslContextFactory factory = new SslContextFactory();
            factory.setSslContext(_sslContext);
            factory.setNeedClientAuth(true);
            connector = new SslSelectChannelConnector(factory);
        }
        else
        {
            throw new IllegalArgumentException("Unexpected transport on port " + _port.getName() + ":" + _transport);
        }
View Full Code Here

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

        if (keystoreFile.exists())
        {
            SslSelectChannelConnector sslConnector = new SslSelectChannelConnector();

            sslConnector.setPort(sslPort);

            sslConnector.setKeystore(keystoreFile.getPath());

            sslConnector.setPassword("tapestry");

            sslConnector.setKeyPassword("tapestry");

            jettyServer.addConnector(sslConnector);
        }

        jettyServer.setHandler(webapp);
View Full Code Here

        else if (_transport == Transport.WSS)
        {
            SslContextFactory factory = new SslContextFactory();
            factory.setSslContext(_sslContext);
            factory.setNeedClientAuth(true);
            connector = new SslSelectChannelConnector(factory);
        }
        else
        {
            throw new IllegalArgumentException("Unexpected transport on port " + _port.getName() + ":" + _transport);
        }
View Full Code Here

    public String getKeystore() {
        return sslKeystore;
    }

    protected SslSelectChannelConnector getSslSocketConnector(JettyHttpEndpoint endpoint) throws Exception {
        SslSelectChannelConnector answer = null;
        if (sslSocketConnectors != null) {
            answer = sslSocketConnectors.get(endpoint.getPort());
        }
        if (answer == null) {
            answer = createSslSocketConnector(endpoint);
View Full Code Here

        }
        return answer;
    }
   
    protected SslSelectChannelConnector createSslSocketConnector(JettyHttpEndpoint endpoint) throws Exception {
        SslSelectChannelConnector answer = null;
       
        // Note that this was set on the endpoint when it was constructed.  It was
        // either explicitly set at the component or on the endpoint, but either way,
        // the value is already set.  We therefore do not need to look at the component
        // level SSLContextParameters again in this method.
        SSLContextParameters endpointSslContextParameters = endpoint.getSslContextParameters();
       
        if (endpointSslContextParameters != null) {
            SslContextFactory contextFact = new SslContextFactory() {

                // This method is for Jetty 7.0.x ~ 7.4.x
                @SuppressWarnings("unused")
                public boolean checkConfig() {
                    if (getSslContext() == null) {
                        return checkSSLContextFactoryConfig(this);
                    } else {
                        return true;
                    }
                }
                // This method is for Jetty 7.5.x
                public void checkKeyStore() {
                    // here we don't check the SslContext as it is already created
                }
               
            };
            contextFact.setSslContext(endpointSslContextParameters.createSSLContext());
            for (Constructor<?> c : SslSelectChannelConnector.class.getConstructors()) {
                if (c.getParameterTypes().length == 1
                    && c.getParameterTypes()[0].isInstance(contextFact)) {
                    answer = (SslSelectChannelConnector)c.newInstance(contextFact);
                }
            }
        } else {
            answer = new SslSelectChannelConnector();
            // with default null values, jetty ssl system properties
            // and console will be read by jetty implementation
   
            String keystoreProperty = System.getProperty(JETTY_SSL_KEYSTORE);
            if (keystoreProperty != null) {
View Full Code Here

    public String getKeystore() {
        return sslKeystore;
    }

    protected SslSelectChannelConnector getSslSocketConnector(JettyHttpEndpoint endpoint) throws Exception {
        SslSelectChannelConnector answer = null;
        if (sslSocketConnectors != null) {
            answer = sslSocketConnectors.get(endpoint.getPort());
        }
        if (answer == null) {
            answer = createSslSocketConnector(endpoint);
View Full Code Here

TOP

Related Classes of org.eclipse.jetty.server.ssl.SslSelectChannelConnector

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.