Search in sources :

Example 1 with FakeTransportConnector

use of org.apache.activemq.broker.FakeTransportConnector in project activemq-artemis by apache.

the class SslBrokerServiceTest method createBroker.

@Override
protected BrokerService createBroker() throws Exception {
    // http://java.sun.com/javase/javaseforbusiness/docs/TLSReadme.html
    // work around: javax.net.ssl.SSLHandshakeException: renegotiation is not allowed
    System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
    SslBrokerService service = new SslBrokerService();
    service.setPersistent(false);
    String baseUri = getBindLocation();
    String uri0 = baseUri + "?" + TransportConstants.SSL_ENABLED_PROP_NAME + "=true&" + TransportConstants.KEYSTORE_PATH_PROP_NAME + "=" + SslTransportBrokerTest.SERVER_KEYSTORE + "&" + TransportConstants.KEYSTORE_PASSWORD_PROP_NAME + "=" + SslTransportBrokerTest.PASSWORD + "&" + TransportConstants.KEYSTORE_PROVIDER_PROP_NAME + "=" + SslTransportBrokerTest.KEYSTORE_TYPE;
    String uri1 = uri0 + "&" + TransportConstants.ENABLED_CIPHER_SUITES_PROP_NAME + "=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,SSL_DH_anon_WITH_3DES_EDE_CBC_SHA";
    String uri2 = uri0 + "&" + TransportConstants.NEED_CLIENT_AUTH_PROP_NAME + "=true&" + TransportConstants.TRUSTSTORE_PATH_PROP_NAME + "=" + SslTransportBrokerTest.TRUST_KEYSTORE + "&" + TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME + "=" + SslTransportBrokerTest.PASSWORD + "&" + TransportConstants.TRUSTSTORE_PROVIDER_PROP_NAME + "=" + SslTransportBrokerTest.KEYSTORE_TYPE;
    // broker side
    TransportConnector serverConnector0 = service.addConnector(new URI(uri0));
    connector = new FakeTransportConnector(new URI("ssl://localhost:" + serverConnector0.getUri().getPort()));
    TransportConnector serverConnector1 = service.addConnector(new URI(uri1));
    limitedCipherSuites = new FakeTransportConnector(new URI("ssl://localhost:" + serverConnector1.getUri().getPort() + "?transport.enabledCipherSuites=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,SSL_DH_anon_WITH_3DES_EDE_CBC_SHA"));
    TransportConnector serverConnector2 = service.addConnector(new URI(uri2));
    needClientAuthConnector = new FakeTransportConnector(new URI("ssl://localhost:" + serverConnector2.getUri().getPort() + "?transport.needClientAuth=true"));
    KeyManager[] km = getKeyManager();
    TrustManager[] tm = getTrustManager();
    // for client side
    SslTransportFactory sslFactory = new SslTransportFactory();
    SslContext ctx = new SslContext(km, tm, null);
    SslContext.setCurrentSslContext(ctx);
    TransportFactory.registerTransportFactory("ssl", sslFactory);
    return service;
}
Also used : FakeTransportConnector(org.apache.activemq.broker.FakeTransportConnector) TransportConnector(org.apache.activemq.broker.TransportConnector) FakeTransportConnector(org.apache.activemq.broker.FakeTransportConnector) SslBrokerService(org.apache.activemq.broker.SslBrokerService) URI(java.net.URI) KeyManager(javax.net.ssl.KeyManager) TrustManager(javax.net.ssl.TrustManager) SslContext(org.apache.activemq.broker.SslContext)

Aggregations

URI (java.net.URI)1 KeyManager (javax.net.ssl.KeyManager)1 TrustManager (javax.net.ssl.TrustManager)1 FakeTransportConnector (org.apache.activemq.broker.FakeTransportConnector)1 SslBrokerService (org.apache.activemq.broker.SslBrokerService)1 SslContext (org.apache.activemq.broker.SslContext)1 TransportConnector (org.apache.activemq.broker.TransportConnector)1