From commits-return-18826-apmail-activemq-commits-archive=activemq.apache.org@activemq.apache.org Fri May 4 14:17:59 2012 Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7390EC5B1 for ; Fri, 4 May 2012 14:17:59 +0000 (UTC) Received: (qmail 28015 invoked by uid 500); 4 May 2012 14:17:59 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 27988 invoked by uid 500); 4 May 2012 14:17:59 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 27981 invoked by uid 99); 4 May 2012 14:17:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 May 2012 14:17:59 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 May 2012 14:17:57 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2DFB62388962 for ; Fri, 4 May 2012 14:17:37 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1333980 - in /activemq/trunk/activemq-optional/src: main/java/org/apache/activemq/transport/https/ test/java/org/apache/activemq/transport/https/ test/resources/ Date: Fri, 04 May 2012 14:17:36 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120504141737.2DFB62388962@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tabish Date: Fri May 4 14:17:36 2012 New Revision: 1333980 URL: http://svn.apache.org/viewvc?rev=1333980&view=rev Log: apply patch for: https://issues.apache.org/jira/browse/AMQ-3827 Added: activemq/trunk/activemq-optional/src/test/java/org/apache/activemq/transport/https/HttpsJmsSendAndReceiveConfigurationSslConfigTest.java (with props) activemq/trunk/activemq-optional/src/test/java/org/apache/activemq/transport/https/HttpsJmsSendAndReceiveEmbeddedSslConfigTest.java (with props) activemq/trunk/activemq-optional/src/test/resources/activemq-https.xml (with props) Modified: activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/HttpsTransportFactory.java activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/HttpsTransportServer.java Modified: activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/HttpsTransportFactory.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/HttpsTransportFactory.java?rev=1333980&r1=1333979&r2=1333980&view=diff ============================================================================== --- activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/HttpsTransportFactory.java (original) +++ activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/HttpsTransportFactory.java Fri May 4 14:17:36 2012 @@ -20,14 +20,15 @@ import java.io.IOException; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; -import java.util.Map; import java.util.HashMap; +import java.util.Map; +import org.apache.activemq.broker.SslContext; import org.apache.activemq.transport.Transport; import org.apache.activemq.transport.TransportServer; import org.apache.activemq.transport.http.HttpTransportFactory; -import org.apache.activemq.util.IntrospectionSupport; import org.apache.activemq.util.IOExceptionSupport; +import org.apache.activemq.util.IntrospectionSupport; import org.apache.activemq.util.URISupport; import org.apache.activemq.wireformat.WireFormat; @@ -43,18 +44,16 @@ public class HttpsTransportFactory exten public TransportServer doBind(URI location) throws IOException { try { Map options = new HashMap(URISupport.parseParameters(location)); - HttpsTransportServer result = new HttpsTransportServer(location, this); + HttpsTransportServer result = new HttpsTransportServer(location, this, SslContext.getCurrentSslContext()); Map transportOptions = IntrospectionSupport.extractProperties(options, "transport."); result.setTransportOption(transportOptions); return result; } catch (URISyntaxException e) { throw IOExceptionSupport.create(e); } - } protected Transport createTransport(URI location, WireFormat wf) throws MalformedURLException { return new HttpsClientTransport(asTextWireFormat(wf), location); } - } Modified: activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/HttpsTransportServer.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/HttpsTransportServer.java?rev=1333980&r1=1333979&r2=1333980&view=diff ============================================================================== --- activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/HttpsTransportServer.java (original) +++ activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/HttpsTransportServer.java Fri May 4 14:17:36 2012 @@ -18,7 +18,11 @@ package org.apache.activemq.transport.ht import java.net.URI; +import javax.net.ssl.SSLContext; + +import org.apache.activemq.broker.SslContext; import org.apache.activemq.transport.http.HttpTransportServer; +import org.eclipse.jetty.util.ssl.SslContextFactory; public class HttpsTransportServer extends HttpTransportServer { @@ -31,41 +35,61 @@ public class HttpsTransportServer extend private String keyCertificateAlgorithm; private String protocol; private String auth; + private SslContext context; - public HttpsTransportServer(URI uri, HttpsTransportFactory factory) { + public HttpsTransportServer(URI uri, HttpsTransportFactory factory, SslContext context) { super(uri, factory); + this.context = context; } public void doStart() throws Exception { Krb5AndCertsSslSocketConnector sslConnector = new Krb5AndCertsSslSocketConnector(); - if(auth != null){ - sslConnector.setMode(auth); - } - - sslConnector.getSslContextFactory().setKeyStore(keyStore); - sslConnector.getSslContextFactory().setKeyStorePassword(keyStorePassword); - // if the keyPassword hasn't been set, default it to the - // key store password - if (keyPassword == null) { - sslConnector.getSslContextFactory().setKeyStorePassword(keyStorePassword); - } - if (keyStoreType != null) { - sslConnector.getSslContextFactory().setKeyStoreType(keyStoreType); - } - if (secureRandomCertficateAlgorithm != null) { - sslConnector.getSslContextFactory().setSecureRandomAlgorithm(secureRandomCertficateAlgorithm); - } - if (keyCertificateAlgorithm != null) { - sslConnector.getSslContextFactory().setSslKeyManagerFactoryAlgorithm(keyCertificateAlgorithm); - } - if (trustCertificateAlgorithm != null) { - sslConnector.getSslContextFactory().setTrustManagerFactoryAlgorithm(trustCertificateAlgorithm); - } - if (protocol != null) { - sslConnector.getSslContextFactory().setProtocol(protocol); - } - + SSLContext sslContext = context == null ? null : context.getSSLContext(); + + // Get a reference to the current ssl context factory... + SslContextFactory factory = sslConnector.getSslContextFactory(); + + if (context != null) { + + // Should not be using this method since it does not use all of the values + // from the passed SslContext instance..... + factory.setSslContext(sslContext); + + } else { + + if (auth != null) { + sslConnector.setMode(auth); + } + + if (keyStore != null) { + factory.setKeyStorePath(keyStore); + } + if (keyStorePassword != null) { + factory.setKeyStorePassword(keyStorePassword); + } + // if the keyPassword hasn't been set, default it to the + // key store password + if (keyPassword == null && keyStorePassword != null) { + factory.setKeyStorePassword(keyStorePassword); + } + if (keyStoreType != null) { + factory.setKeyStoreType(keyStoreType); + } + if (secureRandomCertficateAlgorithm != null) { + factory.setSecureRandomAlgorithm(secureRandomCertficateAlgorithm); + } + if (keyCertificateAlgorithm != null) { + factory.setSslKeyManagerFactoryAlgorithm(keyCertificateAlgorithm); + } + if (trustCertificateAlgorithm != null) { + factory.setTrustManagerFactoryAlgorithm(trustCertificateAlgorithm); + } + if (protocol != null) { + factory.setProtocol(protocol); + } + } + setConnector(sslConnector); super.doStart(); Added: activemq/trunk/activemq-optional/src/test/java/org/apache/activemq/transport/https/HttpsJmsSendAndReceiveConfigurationSslConfigTest.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-optional/src/test/java/org/apache/activemq/transport/https/HttpsJmsSendAndReceiveConfigurationSslConfigTest.java?rev=1333980&view=auto ============================================================================== --- activemq/trunk/activemq-optional/src/test/java/org/apache/activemq/transport/https/HttpsJmsSendAndReceiveConfigurationSslConfigTest.java (added) +++ activemq/trunk/activemq-optional/src/test/java/org/apache/activemq/transport/https/HttpsJmsSendAndReceiveConfigurationSslConfigTest.java Fri May 4 14:17:36 2012 @@ -0,0 +1,85 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.activemq.transport.https; + +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.JmsTopicSendReceiveTest; +import org.apache.activemq.broker.BrokerFactory; +import org.apache.activemq.broker.BrokerService; + +/** + * @author Claudio Corsi + * + */ +public class HttpsJmsSendAndReceiveConfigurationSslConfigTest extends + JmsTopicSendReceiveTest { + + public static final String KEYSTORE_TYPE = "jks"; + public static final String PASSWORD = "password"; + public static final String TRUST_KEYSTORE = "src/test/resources/client.keystore"; + + private BrokerService broker; + + /* + * (non-Javadoc) + * + * @see org.apache.activemq.JmsSendReceiveTestSupport#setUp() + */ + @Override + protected void setUp() throws Exception { + // Create the broker service from the configuration and wait until it + // has been started... + broker = BrokerFactory.createBroker("xbean:activemq-https.xml"); + broker.setPersistent(false); + broker.start(); + broker.waitUntilStarted(); + System.setProperty("javax.net.ssl.trustStore", TRUST_KEYSTORE); + System.setProperty("javax.net.ssl.trustStorePassword", PASSWORD); + System.setProperty("javax.net.ssl.trustStoreType", KEYSTORE_TYPE); + // Remove all references of the javax.net.ssl properties that can impact + // these tests.... + System.getProperties().remove("javax.net.ssl.keyStore"); + System.getProperties().remove("javax.net.ssl.keyStorePassword"); + System.getProperties().remove("javax.net.ssl.keyStoreType"); + super.setUp(); + } + + /* + * (non-Javadoc) + * + * @see org.apache.activemq.AutoFailTestSupport#tearDown() + */ + @Override + protected void tearDown() throws Exception { + super.tearDown(); + if (broker != null) { + broker.stop(); + } + } + + /* + * (non-Javadoc) + * + * @see org.apache.activemq.TestSupport#createConnectionFactory() + */ + @Override + protected ActiveMQConnectionFactory createConnectionFactory() + throws Exception { + return new ActiveMQConnectionFactory("https://localhost:8161"); + } + +} Propchange: activemq/trunk/activemq-optional/src/test/java/org/apache/activemq/transport/https/HttpsJmsSendAndReceiveConfigurationSslConfigTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: activemq/trunk/activemq-optional/src/test/java/org/apache/activemq/transport/https/HttpsJmsSendAndReceiveEmbeddedSslConfigTest.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-optional/src/test/java/org/apache/activemq/transport/https/HttpsJmsSendAndReceiveEmbeddedSslConfigTest.java?rev=1333980&view=auto ============================================================================== --- activemq/trunk/activemq-optional/src/test/java/org/apache/activemq/transport/https/HttpsJmsSendAndReceiveEmbeddedSslConfigTest.java (added) +++ activemq/trunk/activemq-optional/src/test/java/org/apache/activemq/transport/https/HttpsJmsSendAndReceiveEmbeddedSslConfigTest.java Fri May 4 14:17:36 2012 @@ -0,0 +1,99 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.activemq.transport.https; + +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.JmsTopicSendReceiveTest; +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.spring.SpringSslContext; + +/** + * @author Claudio Corsi + * + */ +public class HttpsJmsSendAndReceiveEmbeddedSslConfigTest extends + JmsTopicSendReceiveTest { + + /** + * + */ + private static final String URI_LOCATION = "https://localhost:8161"; + public static final String KEYSTORE_TYPE = "jks"; + public static final String PASSWORD = "password"; + public static final String TRUST_KEYSTORE = "src/test/resources/client.keystore"; + public static final String SERVER_KEYSTORE = "src/test/resources/server.keystore"; + + private BrokerService broker; + + /* + * (non-Javadoc) + * + * @see org.apache.activemq.JmsSendReceiveTestSupport#setUp() + */ + @Override + protected void setUp() throws Exception { + // Create the broker service from the configuration and wait until it + // has been started... + broker = new BrokerService(); + SpringSslContext sslContext = new SpringSslContext(); + sslContext.setKeyStorePassword(PASSWORD); + sslContext.setKeyStore(SERVER_KEYSTORE); + sslContext.setTrustStore(TRUST_KEYSTORE); + sslContext.setTrustStorePassword(PASSWORD); + sslContext.afterPropertiesSet(); // This is required so that the SSLContext instance is generated with the passed information. + broker.setSslContext(sslContext); + broker.addConnector(URI_LOCATION); + broker.setPersistent(false); + broker.setUseJmx(false); + broker.start(); + broker.waitUntilStarted(); + System.setProperty("javax.net.ssl.trustStore", TRUST_KEYSTORE); + System.setProperty("javax.net.ssl.trustStorePassword", PASSWORD); + System.setProperty("javax.net.ssl.trustStoreType", KEYSTORE_TYPE); + // Remove all references of the javax.net.ssl properties that can impact + // these tests.... + System.getProperties().remove("javax.net.ssl.keyStore"); + System.getProperties().remove("javax.net.ssl.keyStorePassword"); + System.getProperties().remove("javax.net.ssl.keyStoreType"); + super.setUp(); + } + + /* + * (non-Javadoc) + * + * @see org.apache.activemq.AutoFailTestSupport#tearDown() + */ + @Override + protected void tearDown() throws Exception { + super.tearDown(); + if (broker != null) { + broker.stop(); + } + } + + /* + * (non-Javadoc) + * + * @see org.apache.activemq.TestSupport#createConnectionFactory() + */ + @Override + protected ActiveMQConnectionFactory createConnectionFactory() + throws Exception { + return new ActiveMQConnectionFactory(URI_LOCATION); + } + +} Propchange: activemq/trunk/activemq-optional/src/test/java/org/apache/activemq/transport/https/HttpsJmsSendAndReceiveEmbeddedSslConfigTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: activemq/trunk/activemq-optional/src/test/resources/activemq-https.xml URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-optional/src/test/resources/activemq-https.xml?rev=1333980&view=auto ============================================================================== --- activemq/trunk/activemq-optional/src/test/resources/activemq-https.xml (added) +++ activemq/trunk/activemq-optional/src/test/resources/activemq-https.xml Fri May 4 14:17:36 2012 @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + Propchange: activemq/trunk/activemq-optional/src/test/resources/activemq-https.xml ------------------------------------------------------------------------------ svn:eol-style = native