public class SampleSSLUtilSetCertManagers extends Object
SSLUtilityFactory
is
used to set the Certificate KeyManagers and TrustManagers of the platform
while creating an ssl connection.
import java.security.SecureRandom; import java.util.List; import javax.net.ssl.KeyManager; import javax.net.ssl.TrustManager; import org.apache.activemq.ActiveMQSslConnectionFactory; import com.avaya.collaboration.reliableeventing.BrokerGroup; import com.avaya.collaboration.reliableeventing.ReliableEventHelper; import com.avaya.collaboration.reliableeventing.ReliableEventingException; import com.avaya.collaboration.reliableeventing.ReliableEventingFactory; import com.avaya.collaboration.ssl.util.SSLUtilityException; import com.avaya.collaboration.ssl.util.SSLUtilityFactory; public class SampleSSLUtilSetCertManagers { public void usingSSLUtilAPI() throws SSLUtilityException, ReliableEventingException { final ActiveMQSslConnectionFactory connectionFactory = new ActiveMQSslConnectionFactory(); final ReliableEventHelper helper = ReliableEventingFactory.getHelper(); final List<BrokerGroup> brokerGroupList = helper.getMyBrokerGroupList(); final String brokerUrl = brokerGroupList.get(0).getBrokerUrlList().get(0); connectionFactory.setBrokerURL(brokerUrl); final List<KeyManager> keyManagers = SSLUtilityFactory.getKeyManagers(); final List<TrustManager> trustManagers = SSLUtilityFactory.getTrustManagers(); // Set the platform's KeyManagers and TrustManagers to the ssl // connection factory connectionFactory.setKeyAndTrustManagers(keyManagers.toArray(new KeyManager[keyManagers.size()]), trustManagers.toArray(new TrustManager[trustManagers.size()]), new SecureRandom()); } }
Copyright © 2016 Avaya. All Rights Reserved.