Package org.apache.camel.util.jsse

Examples of org.apache.camel.util.jsse.SSLContextParameters


        // NOTE: Needed since the client uses a loose trust configuration when no ssl context
        // is provided.  We turn on WANT client-auth to prefer using authentication
        SSLContextServerParameters scsp = new SSLContextServerParameters();
        scsp.setClientAuthentication(ClientAuthentication.WANT.name());

        SSLContextParameters sslContextParameters = new SSLContextParameters();
        sslContextParameters.setKeyManagers(kmp);
        sslContextParameters.setTrustManagers(tmp);
        sslContextParameters.setServerParameters(scsp);
        // use SSLv3 to avoid issue with (eg disable TLS)
        // Caused by: javax.net.ssl.SSLException: bad record MAC
        sslContextParameters.setSecureSocketProtocol("SSLv3");

        registry.bind("sslContextParameters", sslContextParameters);
    }
View Full Code Here


public class JsseUtilTest extends OSGiIntegrationSpringTestSupport {
   
    @Test
    public void testSslContextParameters() throws Exception {
       
        SSLContextParameters scp = this.applicationContext.getBean(SSLContextParameters.class);
       
        assertEquals("TLS", scp.getSecureSocketProtocol());
       
        assertNotNull(scp.getKeyManagers());
        assertEquals("changeit", scp.getKeyManagers().getKeyPassword());
        assertNull(scp.getKeyManagers().getProvider());
        assertNotNull(scp.getKeyManagers().getKeyStore());
        assertNull(scp.getKeyManagers().getKeyStore().getType());
       
        assertNotNull(scp.getTrustManagers());
        assertNull(scp.getTrustManagers().getProvider());
        assertNotNull(scp.getTrustManagers().getKeyStore());
        assertNull(scp.getTrustManagers().getKeyStore().getType());
       
        assertNull(scp.getSecureRandom());
       
        assertNull(scp.getClientParameters());
       
        assertNull(scp.getServerParameters());
       
        // Test that the instantiation will work when running in OSGi and using
        // class path resources.
        scp.createSSLContext();
    }
View Full Code Here

        // NOTE: Needed since the client uses a loose trust configuration when no ssl context
        // is provided.  We turn on WANT client-auth to prefer using authentication
        SSLContextServerParameters scsp = new SSLContextServerParameters();
        scsp.setClientAuthentication(ClientAuthentication.WANT.name());

        SSLContextParameters sslContextParameters = new SSLContextParameters();
        sslContextParameters.setKeyManagers(kmp);
        sslContextParameters.setTrustManagers(tmp);
        sslContextParameters.setServerParameters(scsp);

        JndiRegistry registry = super.createRegistry();
        registry.bind("sslContextParameters", sslContextParameters);
        return registry;
    }
View Full Code Here

        X509HostnameVerifier x509HostnameVerifier = resolveAndRemoveReferenceParameter(parameters, "x509HostnameVerifier", X509HostnameVerifier.class);
        if (x509HostnameVerifier == null) {
            x509HostnameVerifier = this.x509HostnameVerifier;
        }
       
        SSLContextParameters sslContextParameters = resolveAndRemoveReferenceParameter(parameters, "sslContextParametersRef", SSLContextParameters.class);
        if (sslContextParameters == null) {
            sslContextParameters = this.sslContextParameters;
        }
       
        boolean secure = HttpHelper.isSecureConnection(uri);
View Full Code Here

        Boolean enableMultipartFilter = getAndRemoveParameter(parameters, "enableMultipartFilter",
                                                              Boolean.class, true);
        Filter multipartFilter = resolveAndRemoveReferenceParameter(parameters, "multipartFilterRef", Filter.class);
        Long continuationTimeout = getAndRemoveParameter(parameters, "continuationTimeout", Long.class);
        Boolean useContinuation = getAndRemoveParameter(parameters, "useContinuation", Boolean.class);
        SSLContextParameters sslContextParameters = resolveAndRemoveReferenceParameter(parameters, "sslContextParametersRef", SSLContextParameters.class);
       
       
        // configure http client if we have url configuration for it
        // http client is only used for jetty http producer (hence not very commonly used)
        HttpClient client = null;
        if (IntrospectionSupport.hasProperties(parameters, "httpClient.") || sslContextParameters != null) {
            client = getNewHttpClient();
           
            if (IntrospectionSupport.hasProperties(parameters, "httpClient.")) {
                if (isExplicitHttpClient) {
                    LOG.warn("The user explicitly set an HttpClient instance on the component, "
                             + "but this endpoint provides HttpClient configuration.  Are you sure that "
                             + "this is what was intended?  Applying endpoint configuration to a new HttpClient instance "
                             + "to avoid altering existing HttpClient instances.");
                }
           
                // set additional parameters on http client
                IntrospectionSupport.setProperties(client, parameters, "httpClient.");
                // validate that we could resolve all httpClient. parameters as this component is lenient
                validateParameters(uri, parameters, "httpClient.");
            }
           
            // Note that the component level instance is already configured in getNewHttpClient.
            // We replace it here for endpoint level config.
            if (sslContextParameters != null) {
                if (isExplicitHttpClient) {
                    LOG.warn("The user explicitly set an HttpClient instance on the component, "
                             + "but this endpoint provides SSLContextParameters configuration.  Are you sure that "
                             + "this is what was intended?  Applying endpoint configuration to a new HttpClient instance "
                             + "to avoid altering existing HttpClient instances.");
                }
               
                ((CamelHttpClient) client).setSSLContext(sslContextParameters.createSSLContext());
            }
        } else {
            // Either we use the default one created by the component or we are using
            // one explicitly set by the end user, either way, we just use it as is.
            client = getHttpClient();
View Full Code Here

       
        // 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() {
                /**
                 * We are going to provide the context so none of the configuration options
                 * matter in the factory.  This method does not account for this scenario so
                 * we short-circuit it here to just let things go when the context is already
                 * provided.
                 */
                @Override
                public boolean checkConfig() {
                    if (getSslContext() == null) {
                        return super.checkConfig();
                    } else {
                        return true;
                    }
                }
               
            };
            contextFact.setSslContext(endpointSslContextParameters.createSSLContext());
            answer = new SslSelectChannelConnector(contextFact);
        } else {
            answer = new SslSelectChannelConnector();
            // with default null values, jetty ssl system properties
            // and console will be read by jetty implementation
View Full Code Here

    }

    @Override
    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {

        SSLContextParameters sslContextParameters = resolveAndRemoveReferenceParameter(parameters, "sslContextParametersRef", SSLContextParameters.class);
        Boolean enableJmx = getAndRemoveParameter(parameters, "enableJmx", Boolean.class);
        String staticResources = getAndRemoveParameter(parameters, "staticResources", String.class);
        int port = extractPortNumber(remaining);
        String host = extractHostName(remaining);
View Full Code Here

        kmp.setKeyStore(ksp);

        TrustManagersParameters tmp = new TrustManagersParameters();
        tmp.setKeyStore(ksp);
       
        SSLContextParameters sslContextParameters = new SSLContextParameters();
        sslContextParameters.setKeyManagers(kmp);
        sslContextParameters.setTrustManagers(tmp);

        registry.bind("sslContextParameters", sslContextParameters);
    }
View Full Code Here

        X509HostnameVerifier x509HostnameVerifier = resolveAndRemoveReferenceParameter(parameters, "x509HostnameVerifier", X509HostnameVerifier.class);
        if (x509HostnameVerifier == null) {
            x509HostnameVerifier = getX509HostnameVerifier();
        }
       
        SSLContextParameters sslContextParameters = resolveAndRemoveReferenceParameter(parameters, "sslContextParametersRef", SSLContextParameters.class);
        if (sslContextParameters == null) {
            sslContextParameters = getSslContextParameters();
        }
       
        boolean secure = HttpHelper.isSecureConnection(uri);
View Full Code Here

                                                              Boolean.class, true);
        Filter multipartFilter = resolveAndRemoveReferenceParameter(parameters, "multipartFilterRef", Filter.class);
        List<Filter> filters = resolveAndRemoveReferenceListParameter(parameters, "filtersRef", Filter.class);
        Long continuationTimeout = getAndRemoveParameter(parameters, "continuationTimeout", Long.class);
        Boolean useContinuation = getAndRemoveParameter(parameters, "useContinuation", Boolean.class);
        SSLContextParameters sslContextParameters = resolveAndRemoveReferenceParameter(parameters, "sslContextParametersRef", SSLContextParameters.class);
       
       
        // configure http client if we have url configuration for it
        // http client is only used for jetty http producer (hence not very commonly used)
        HttpClient client = null;
        if (IntrospectionSupport.hasProperties(parameters, "httpClient.") || sslContextParameters != null) {
            client = getNewHttpClient();
           
            if (IntrospectionSupport.hasProperties(parameters, "httpClient.")) {
                if (isExplicitHttpClient) {
                    LOG.warn("The user explicitly set an HttpClient instance on the component, "
                             + "but this endpoint provides HttpClient configuration.  Are you sure that "
                             + "this is what was intended?  Applying endpoint configuration to a new HttpClient instance "
                             + "to avoid altering existing HttpClient instances.");
                }
           
                // set additional parameters on http client
                IntrospectionSupport.setProperties(client, parameters, "httpClient.");
                // validate that we could resolve all httpClient. parameters as this component is lenient
                validateParameters(uri, parameters, "httpClient.");
            }
           
            // Note that the component level instance is already configured in getNewHttpClient.
            // We replace it here for endpoint level config.
            if (sslContextParameters != null) {
                if (isExplicitHttpClient) {
                    LOG.warn("The user explicitly set an HttpClient instance on the component, "
                             + "but this endpoint provides SSLContextParameters configuration.  Are you sure that "
                             + "this is what was intended?  Applying endpoint configuration to a new HttpClient instance "
                             + "to avoid altering existing HttpClient instances.");
                }
               
                ((CamelHttpClient) client).setSSLContext(sslContextParameters.createSSLContext());
            }
        } else {
            // Either we use the default one created by the component or we are using
            // one explicitly set by the end user, either way, we just use it as is.
            client = getHttpClient();
View Full Code Here

TOP

Related Classes of org.apache.camel.util.jsse.SSLContextParameters

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.