Remove the commons log reference and unused logger. 

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1374231 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2012-08-17 12:55:35 +00:00
parent 3c39db8cce
commit e49f5d9ff8
1 changed files with 44 additions and 46 deletions

View File

@ -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.LogFactory;
* 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 ActiveMQSslConnectionFactory extends ActiveMQConnectionFactory {
/**
* 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 ActiveMQSslConnectionFactory extends ActiveMQConnectionFactory {
* 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 ActiveMQSslConnectionFactory extends ActiveMQConnectionFactory {
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 ActiveMQSslConnectionFactory extends ActiveMQConnectionFactory {
keystoreManagers = kmf.getKeyManagers();
}
}
return keystoreManagers;
return keystoreManagers;
}
protected byte[] loadClientCredential(String fileName) throws IOException {
@ -168,79 +166,79 @@ public class ActiveMQSslConnectionFactory extends ActiveMQConnectionFactory {
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.
*/