You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2012/08/17 14:55:35 UTC

svn commit: r1374231 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSslConnectionFactory.java

Author: tabish
Date: Fri Aug 17 12:55:35 2012
New Revision: 1374231

URL: http://svn.apache.org/viewvc?rev=1374231&view=rev
Log:
fix for: https://issues.apache.org/jira/browse/AMQ-3981

Remove the commons log reference and unused logger. 

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSslConnectionFactory.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSslConnectionFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSslConnectionFactory.java?rev=1374231&r1=1374230&r2=1374231&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSslConnectionFactory.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSslConnectionFactory.java Fri Aug 17 12:55:35 2012
@@ -21,12 +21,12 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.security.KeyStore;
-
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
+import java.security.KeyStore;
 import java.security.SecureRandom;
+
 import javax.jms.JMSException;
 import javax.net.ssl.KeyManager;
 import javax.net.ssl.KeyManagerFactory;
@@ -36,8 +36,6 @@ import javax.net.ssl.TrustManagerFactory
 import org.apache.activemq.broker.SslContext;
 import org.apache.activemq.transport.Transport;
 import org.apache.activemq.util.JMSExceptionSupport;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 /**
  * An ActiveMQConnectionFactory that allows access to the key and trust managers
@@ -45,19 +43,19 @@ import org.apache.commons.logging.LogFac
  * being used AND the key and trust managers need to be specified from within
  * code. In fact, if the URI passed to this class does not have an "ssl" scheme,
  * this class will pass all work on to its superclass.
- * 
+ *
  * There are two alternative approaches you can use to provide X.509 certificates
  * for the SSL connections:
- * 
+ *
  * Call <code>setTrustStore</code>, <code>setTrustStorePassword</code>, <code>setKeyStore</code>,
  * and <code>setKeyStorePassword</code>.
- * 
+ *
  * Call <code>setKeyAndTrustManagers</code>.
- * 
+ *
  * @author sepandm@gmail.com
  */
 public class ActiveMQSslConnectionFactory extends ActiveMQConnectionFactory {
-    private static final Log LOG = LogFactory.getLog(ActiveMQSslConnectionFactory.class);
+
     // The key and trust managers used to initialize the used SSLContext.
     protected KeyManager[] keyManager;
     protected TrustManager[] trustManager;
@@ -81,7 +79,7 @@ public class ActiveMQSslConnectionFactor
 
     /**
      * Sets the key and trust managers used when creating SSL connections.
-     * 
+     *
      * @param km The KeyManagers used.
      * @param tm The TrustManagers used.
      * @param random The SecureRandom number used.
@@ -97,7 +95,7 @@ public class ActiveMQSslConnectionFactor
      * not using SSL, the superclass's method is called. If we are using SSL, an
      * SslConnectionFactory is used and it is given the needed key and trust
      * managers.
-     * 
+     *
      * @author sepandm@gmail.com
      */
     protected Transport createTransport() throws JMSException {
@@ -132,12 +130,12 @@ public class ActiveMQSslConnectionFactor
             tmf.init(trustedCertStore);
             trustStoreManagers = tmf.getTrustManagers();
         }
-        return trustStoreManagers; 
+        return trustStoreManagers;
     }
 
     protected KeyManager[] createKeyManager() throws Exception {
-        KeyManagerFactory kmf = 
-            KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());  
+        KeyManagerFactory kmf =
+            KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
         KeyStore ks = KeyStore.getInstance("jks");
         KeyManager[] keystoreManagers = null;
         if (keyStore != null) {
@@ -150,7 +148,7 @@ public class ActiveMQSslConnectionFactor
                 keystoreManagers = kmf.getKeyManagers();
             }
         }
-        return keystoreManagers;          
+        return keystoreManagers;
     }
 
     protected byte[] loadClientCredential(String fileName) throws IOException {
@@ -168,79 +166,79 @@ public class ActiveMQSslConnectionFactor
         in.close();
         return out.toByteArray();
     }
-    
+
     protected InputStream getUrlOrResourceAsStream(String urlOrResource) throws IOException {
-    	InputStream ins = null;
-    	try {
-    		URL url = new URL(urlOrResource);
-    		ins = url.openStream();
-    	}
-    	catch (MalformedURLException ignore) {
-    		ins = null;
-    	}
-    	
-    	// Alternatively, treat as classpath resource
-    	if (ins == null) {
-        	ins = getClass().getClassLoader().getResourceAsStream(urlOrResource);
-    	}
-    	
-    	if (ins == null) {
+        InputStream ins = null;
+        try {
+            URL url = new URL(urlOrResource);
+            ins = url.openStream();
+        }
+        catch (MalformedURLException ignore) {
+            ins = null;
+        }
+
+        // Alternatively, treat as classpath resource
+        if (ins == null) {
+            ins = getClass().getClassLoader().getResourceAsStream(urlOrResource);
+        }
+
+        if (ins == null) {
             throw new java.io.IOException("Could not load resource: " + urlOrResource);
-    	}
-    	
-    	return ins;
+        }
+
+        return ins;
     }
-    
+
     public String getTrustStore() {
         return trustStore;
     }
-    
+
     /**
      * The location of a keystore file (in <code>jks</code> format) containing one or more
      * trusted certificates.
-     * 
+     *
      * @param trustStore If specified with a scheme, treat as a URL, otherwise treat as a classpath resource.
      */
     public void setTrustStore(String trustStore) throws Exception {
         this.trustStore = trustStore;
         trustManager = null;
     }
-    
+
     public String getTrustStorePassword() {
         return trustStorePassword;
     }
-    
+
     /**
      * The password to match the trust store specified by {@link setTrustStore}.
-     * 
+     *
      * @param trustStorePassword The password used to unlock the keystore file.
      */
     public void setTrustStorePassword(String trustStorePassword) {
         this.trustStorePassword = trustStorePassword;
     }
-    
+
     public String getKeyStore() {
         return keyStore;
     }
-    
+
     /**
      * The location of a keystore file (in <code>jks</code> format) containing a certificate
      * and its private key.
-     * 
+     *
      * @param keyStore If specified with a scheme, treat as a URL, otherwise treat as a classpath resource.
      */
     public void setKeyStore(String keyStore) throws Exception {
         this.keyStore = keyStore;
         keyManager = null;
     }
-    
+
     public String getKeyStorePassword() {
         return keyStorePassword;
     }
-    
+
     /**
      * The password to match the key store specified by {@link setKeyStore}.
-     * 
+     *
      * @param keyStorePassword The password, which is used both to unlock the keystore file
      * and as the pass phrase for the private key stored in the keystore.
      */