1 18 19 package org.apache.activemq.broker; 20 21 import org.apache.activemq.transport.TransportFactory; 22 import org.apache.activemq.transport.TransportServer; 23 import org.apache.activemq.transport.tcp.SslTransportFactory; 24 25 import java.io.IOException ; 26 import java.net.URI ; 27 import java.security.KeyManagementException ; 28 import java.security.SecureRandom ; 29 30 import javax.net.ssl.KeyManager; 31 import javax.net.ssl.TrustManager; 32 33 42 public class SslBrokerService extends BrokerService { 43 57 58 public TransportConnector addSslConnector( 59 String bindAddress, 60 KeyManager[] km, 61 TrustManager[] tm, 62 SecureRandom random) throws Exception { 63 return addSslConnector( new URI (bindAddress), km, tm, random ); 64 } 65 66 80 public TransportConnector addSslConnector( 81 URI bindAddress, 82 KeyManager[] km, 83 TrustManager[] tm, 84 SecureRandom random) throws Exception { 85 return addConnector(createSslTransportServer(bindAddress, km, tm, random)); 86 } 87 88 101 protected TransportServer createSslTransportServer( 102 URI brokerURI, 103 KeyManager[] km, 104 TrustManager[] tm, 105 SecureRandom random) throws IOException , KeyManagementException { 106 107 if (brokerURI.getScheme().equals("ssl")) { 108 SslTransportFactory transportFactory = new SslTransportFactory(); 111 transportFactory.setKeyAndTrustManagers(km, tm, random); 112 113 return transportFactory.doBind(getBrokerName(),brokerURI); 114 } else { 115 return TransportFactory.bind(getBrokerName(), brokerURI); 117 } 118 } 119 } 120 | Popular Tags |