org.apache.activemq
Class ActiveMQSslConnectionFactory

java.lang.Object
  extended by org.apache.activemq.jndi.JNDIBaseStorable
      extended by org.apache.activemq.ActiveMQConnectionFactory
          extended by org.apache.activemq.ActiveMQSslConnectionFactory
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, javax.jms.ConnectionFactory, javax.jms.QueueConnectionFactory, javax.jms.TopicConnectionFactory, javax.naming.Referenceable, JNDIStorableInterface, StatsCapable

public class ActiveMQSslConnectionFactory
extends ActiveMQConnectionFactory

An ActiveMQConnectionFactory that allows access to the key and trust managers used for SslConnections. There is no reason to use this class unless SSL is 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 setTrustStore, setTrustStorePassword, setKeyStore, and setKeyStorePassword. Call setKeyAndTrustManagers.

Author:
sepandm@gmail.com
See Also:
Serialized Form

Field Summary
protected  javax.net.ssl.KeyManager[] keyManager
           
protected  java.lang.String keyStore
           
protected  java.lang.String keyStorePassword
           
protected  java.security.SecureRandom secureRandom
           
protected  javax.net.ssl.TrustManager[] trustManager
           
protected  java.lang.String trustStore
           
protected  java.lang.String trustStorePassword
           
 
Fields inherited from class org.apache.activemq.ActiveMQConnectionFactory
alwaysSessionAsync, brokerURL, clientID, DEFAULT_BROKER_BIND_URL, DEFAULT_BROKER_URL, DEFAULT_CONNECTION_EXECUTOR, DEFAULT_PASSWORD, DEFAULT_PRODUCER_WINDOW_SIZE, DEFAULT_USER, dispatchAsync, password, userName
 
Constructor Summary
ActiveMQSslConnectionFactory()
           
ActiveMQSslConnectionFactory(java.lang.String brokerURL)
           
ActiveMQSslConnectionFactory(java.net.URI brokerURL)
           
 
Method Summary
protected  javax.net.ssl.KeyManager[] createKeyManager()
           
protected  Transport createTransport()
          Overriding to make special considerations for SSL connections.
protected  javax.net.ssl.TrustManager[] createTrustManager()
           
 java.lang.String getKeyStore()
           
 java.lang.String getKeyStorePassword()
           
 java.lang.String getTrustStore()
           
 java.lang.String getTrustStorePassword()
           
protected  java.io.InputStream getUrlOrResourceAsStream(java.lang.String urlOrResource)
           
protected  byte[] loadClientCredential(java.lang.String fileName)
           
 void setKeyAndTrustManagers(javax.net.ssl.KeyManager[] km, javax.net.ssl.TrustManager[] tm, java.security.SecureRandom random)
          Sets the key and trust managers used when creating SSL connections.
 void setKeyStore(java.lang.String keyStore)
          The location of a keystore file (in jks format) containing a certificate and its private key.
 void setKeyStorePassword(java.lang.String keyStorePassword)
          The password to match the key store specified by setKeyStore.
 void setTrustStore(java.lang.String trustStore)
          The location of a keystore file (in jks format) containing one or more trusted certificates.
 void setTrustStorePassword(java.lang.String trustStorePassword)
          The password to match the trust store specified by setTrustStore.
 
Methods inherited from class org.apache.activemq.ActiveMQConnectionFactory
buildFromMap, buildFromProperties, configureConnection, copy, createActiveMQConnection, createActiveMQConnection, createActiveMQConnection, createConnection, createConnection, createQueueConnection, createQueueConnection, createTopicConnection, createTopicConnection, getAuditDepth, getAuditMaximumProducerNumber, getBlobTransferPolicy, getBrokerURL, getClientID, getClientIdGenerator, getClientIDPrefix, getClientInternalExceptionListener, getCloseTimeout, getConnectionIdGenerator, getConsumerFailoverRedeliveryWaitPeriod, getExceptionListener, getOptimizeAcknowledgeTimeOut, getPassword, getPrefetchPolicy, getProducerWindowSize, getRedeliveryPolicy, getSendTimeout, getStats, getTransformer, getTransportListener, getUserName, getWarnAboutUnstartedConnectionTimeout, isAlwaysSessionAsync, isAlwaysSyncSend, isCheckForDuplicates, isCopyMessageOnSend, isDisableTimeStampsByDefault, isDispatchAsync, isExclusiveConsumer, isMessagePrioritySupported, isNestedMapAndListEnabled, isNonBlockingRedelivery, isObjectMessageSerializationDefered, isOptimizeAcknowledge, isOptimizedMessageDispatch, isSendAcksAsync, isStatsEnabled, isTransactedIndividualAck, isUseAsyncSend, isUseCompression, isUseDedicatedTaskRunner, isUseRetroactiveConsumer, isWatchTopicAdvisories, populateProperties, setAlwaysSessionAsync, setAlwaysSyncSend, setAuditDepth, setAuditMaximumProducerNumber, setBlobTransferPolicy, setBrokerURL, setCheckForDuplicates, setClientID, setClientIdGenerator, setClientIDPrefix, setClientInternalExceptionListener, setCloseTimeout, setConnectionIdGenerator, setConnectionIDPrefix, setConsumerFailoverRedeliveryWaitPeriod, setCopyMessageOnSend, setDisableTimeStampsByDefault, setDispatchAsync, setExceptionListener, setExclusiveConsumer, setMessagePrioritySupported, setNestedMapAndListEnabled, setNonBlockingRedelivery, setObjectMessageSerializationDefered, setOptimizeAcknowledge, setOptimizeAcknowledgeTimeOut, setOptimizedMessageDispatch, setPassword, setPrefetchPolicy, setProducerWindowSize, setRedeliveryPolicy, setSendAcksAsync, setSendTimeout, setStatsEnabled, setTransactedIndividualAck, setTransformer, setTransportListener, setUseAsyncSend, setUseCompression, setUseDedicatedTaskRunner, setUseRetroactiveConsumer, setUserName, setWarnAboutUnstartedConnectionTimeout, setWatchTopicAdvisories
 
Methods inherited from class org.apache.activemq.jndi.JNDIBaseStorable
getProperties, getReference, readExternal, setProperties, writeExternal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

keyManager

protected javax.net.ssl.KeyManager[] keyManager

trustManager

protected javax.net.ssl.TrustManager[] trustManager

secureRandom

protected java.security.SecureRandom secureRandom

trustStore

protected java.lang.String trustStore

trustStorePassword

protected java.lang.String trustStorePassword

keyStore

protected java.lang.String keyStore

keyStorePassword

protected java.lang.String keyStorePassword
Constructor Detail

ActiveMQSslConnectionFactory

public ActiveMQSslConnectionFactory()

ActiveMQSslConnectionFactory

public ActiveMQSslConnectionFactory(java.lang.String brokerURL)

ActiveMQSslConnectionFactory

public ActiveMQSslConnectionFactory(java.net.URI brokerURL)
Method Detail

setKeyAndTrustManagers

public void setKeyAndTrustManagers(javax.net.ssl.KeyManager[] km,
                                   javax.net.ssl.TrustManager[] tm,
                                   java.security.SecureRandom random)
Sets the key and trust managers used when creating SSL connections.

Parameters:
km - The KeyManagers used.
tm - The TrustManagers used.
random - The SecureRandom number used.

createTransport

protected Transport createTransport()
                             throws javax.jms.JMSException
Overriding to make special considerations for SSL connections. If we are 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.

Overrides:
createTransport in class ActiveMQConnectionFactory
Returns:
The newly created Transport.
Throws:
javax.jms.JMSException - If unable to create trasnport.

createTrustManager

protected javax.net.ssl.TrustManager[] createTrustManager()
                                                   throws java.lang.Exception
Throws:
java.lang.Exception

createKeyManager

protected javax.net.ssl.KeyManager[] createKeyManager()
                                               throws java.lang.Exception
Throws:
java.lang.Exception

loadClientCredential

protected byte[] loadClientCredential(java.lang.String fileName)
                               throws java.io.IOException
Throws:
java.io.IOException

getUrlOrResourceAsStream

protected java.io.InputStream getUrlOrResourceAsStream(java.lang.String urlOrResource)
                                                throws java.io.IOException
Throws:
java.io.IOException

getTrustStore

public java.lang.String getTrustStore()

setTrustStore

public void setTrustStore(java.lang.String trustStore)
The location of a keystore file (in jks format) containing one or more trusted certificates.

Parameters:
trustStore - If specified with a scheme, treat as a URL, otherwise treat as a classpath resource.

getTrustStorePassword

public java.lang.String getTrustStorePassword()

setTrustStorePassword

public void setTrustStorePassword(java.lang.String trustStorePassword)
The password to match the trust store specified by setTrustStore.

Parameters:
trustStorePassword - The password used to unlock the keystore file.

getKeyStore

public java.lang.String getKeyStore()

setKeyStore

public void setKeyStore(java.lang.String keyStore)
The location of a keystore file (in jks format) containing a certificate and its private key.

Parameters:
keyStore - If specified with a scheme, treat as a URL, otherwise treat as a classpath resource.

getKeyStorePassword

public java.lang.String getKeyStorePassword()

setKeyStorePassword

public void setKeyStorePassword(java.lang.String keyStorePassword)
The password to match the key store specified by setKeyStore.

Parameters:
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.


Copyright © 2005-2016. All Rights Reserved.