001 /*
002 * Created on 12-Aug-2005
003 */
004 package org.activemq.transport.https;
005
006 import java.net.URI;
007
008 import javax.jms.JMSException;
009
010 import org.activemq.transport.http.HttpTransportConnector;
011 import org.apache.commons.logging.Log;
012 import org.apache.commons.logging.LogFactory;
013 import org.mortbay.http.SslListener;
014
015 public class HttpsTransportConnector extends HttpTransportConnector {
016
017 private static final Log log = LogFactory.getLog( HttpsTransportConnector.class );
018
019 private String keyPassword = System.getProperty( "javax.net.ssl.keyPassword" );
020 private String keyStorePassword = System.getProperty( "javax.net.ssl.keyStorePassword" );
021 private String keyStore = System.getProperty( "javax.net.ssl.keyStore" );
022 private String keyStoreType = null;
023 private String certificateAlgorithm = null;
024 private String protocol = null;
025
026 public HttpsTransportConnector( URI uri ) {
027 super( uri );
028 }
029
030 public void start() throws JMSException {
031 SslListener sslListener = new SslListener();
032 sslListener.setKeystore( keyStore );
033 sslListener.setPassword( keyStorePassword );
034 // if the keyPassword hasn't been set, default it to the
035 // key store password
036 if ( keyPassword == null ) {
037 sslListener.setKeyPassword( keyStorePassword );
038 }
039 if ( keyStoreType != null ) {
040 sslListener.setKeystoreType( keyStoreType );
041 }
042 if ( certificateAlgorithm != null ) {
043 sslListener.setAlgorithm( certificateAlgorithm );
044 }
045 if ( protocol != null ) {
046 sslListener.setProtocol( protocol );
047 }
048
049 setSocketListener( sslListener );
050
051 super.start();
052 }
053
054 // Properties
055 //--------------------------------------------------------------------------------
056
057 public String getCertificateAlgorithm() {
058 return certificateAlgorithm;
059 }
060
061 public void setCertificateAlgorithm( String certificateAlgorithm ) {
062 this.certificateAlgorithm = certificateAlgorithm;
063 }
064
065 public String getKeyStore() {
066 return keyStore;
067 }
068
069 public void setKeyStore( String keyStore ) {
070 this.keyStore = keyStore;
071 }
072
073 public String getKeyPassword() {
074 return keyPassword;
075 }
076
077 public void setKeyPassword( String keyPassword ) {
078 this.keyPassword = keyPassword;
079 }
080
081 public String getKeyStoreType() {
082 return keyStoreType;
083 }
084
085 public void setKeyStoreType( String keyStoreType ) {
086 this.keyStoreType = keyStoreType;
087 }
088
089 public String getKeyStorePassword() {
090 return keyStorePassword;
091 }
092
093 public void setKeyStorePassword( String keyStorePassword ) {
094 this.keyStorePassword = keyStorePassword;
095 }
096
097 public String getProtocol() {
098 return protocol;
099 }
100
101 public void setProtocol( String protocol ) {
102 this.protocol = protocol;
103 }
104
105 }