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:
Externalizable, Serializable, Cloneable, ConnectionFactory, QueueConnectionFactory, TopicConnectionFactory, 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  KeyManager[] keyManager
           
protected  String keyStore
           
protected  String keyStorePassword
           
protected  SecureRandom secureRandom
           
protected  TrustManager[] trustManager
           
protected  String trustStore
           
protected  String trustStorePassword
           
 
Fields inherited from class org.apache.activemq.ActiveMQConnectionFactory
alwaysSessionAsync, brokerURL, clientID, DEFAULT_BROKER_BIND_URL, DEFAULT_BROKER_URL, DEFAULT_PASSWORD, DEFAULT_PRODUCER_WINDOW_SIZE, DEFAULT_USER, dispatchAsync, password, userName
 
Constructor Summary
ActiveMQSslConnectionFactory()
           
ActiveMQSslConnectionFactory(String brokerURL)
           
ActiveMQSslConnectionFactory(URI brokerURL)
           
 
Method Summary
protected  KeyManager[] createKeyManager()
           
protected  Transport createTransport()
          Overriding to make special considerations for SSL connections.
protected  TrustManager[] createTrustManager()
           
protected  InputStream getInputStream(String urlOrResource)
           
 String getKeyStore()
           
 String getKeyStorePassword()
           
 String getTrustStore()
           
 String getTrustStorePassword()
           
protected  byte[] loadClientCredential(String fileName)
           
 void setKeyAndTrustManagers(KeyManager[] km, TrustManager[] tm, SecureRandom random)
          Sets the key and trust managers used when creating SSL connections.
 void setKeyStore(String keyStore)
          The location of a keystore file (in jks format) containing a certificate and its private key.
 void setKeyStorePassword(String keyStorePassword)
          The password to match the key store specified by setKeyStore.
 void setTrustStore(String trustStore)
          The location of a keystore file (in jks format) containing one or more trusted certificates.
 void setTrustStorePassword(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, getMaxThreadPoolSize, getOptimizeAcknowledgeTimeOut, getOptimizedAckScheduledAckInterval, getPassword, getPrefetchPolicy, getProducerWindowSize, getRedeliveryPolicy, getRedeliveryPolicyMap, getRejectedTaskHandler, getSendTimeout, getSessionTaskRunner, 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, setMaxThreadPoolSize, setMessagePrioritySupported, setNestedMapAndListEnabled, setNonBlockingRedelivery, setObjectMessageSerializationDefered, setOptimizeAcknowledge, setOptimizeAcknowledgeTimeOut, setOptimizedAckScheduledAckInterval, setOptimizedMessageDispatch, setPassword, setPrefetchPolicy, setProducerWindowSize, setRedeliveryPolicy, setRedeliveryPolicyMap, setRejectedTaskHandler, setSendAcksAsync, setSendTimeout, setSessionTaskRunner, 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 KeyManager[] keyManager

trustManager

protected TrustManager[] trustManager

secureRandom

protected SecureRandom secureRandom

trustStore

protected String trustStore

trustStorePassword

protected String trustStorePassword

keyStore

protected String keyStore

keyStorePassword

protected String keyStorePassword
Constructor Detail

ActiveMQSslConnectionFactory

public ActiveMQSslConnectionFactory()

ActiveMQSslConnectionFactory

public ActiveMQSslConnectionFactory(String brokerURL)

ActiveMQSslConnectionFactory

public ActiveMQSslConnectionFactory(URI brokerURL)
Method Detail

setKeyAndTrustManagers

public void setKeyAndTrustManagers(KeyManager[] km,
                                   TrustManager[] tm,
                                   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 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:
JMSException - If unable to create trasnport.

createTrustManager

protected TrustManager[] createTrustManager()
                                     throws Exception
Throws:
Exception

createKeyManager

protected KeyManager[] createKeyManager()
                                 throws Exception
Throws:
Exception

loadClientCredential

protected byte[] loadClientCredential(String fileName)
                               throws IOException
Throws:
IOException

getInputStream

protected InputStream getInputStream(String urlOrResource)
                              throws IOException
Throws:
IOException

getTrustStore

public String getTrustStore()

setTrustStore

public void setTrustStore(String trustStore)
                   throws Exception
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.
Throws:
Exception

getTrustStorePassword

public String getTrustStorePassword()

setTrustStorePassword

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

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

getKeyStore

public String getKeyStore()

setKeyStore

public void setKeyStore(String keyStore)
                 throws Exception
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.
Throws:
Exception

getKeyStorePassword

public String getKeyStorePassword()

setKeyStorePassword

public void setKeyStorePassword(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-2013 The Apache Software Foundation. All Rights Reserved.