KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > transport > https > HttpsTransportServer


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq.transport.https;
19
20 import org.apache.activemq.transport.http.HttpTransportServer;
21 import org.mortbay.jetty.security.SslSocketConnector;
22
23 import java.net.URI JavaDoc;
24
25 public class HttpsTransportServer extends HttpTransportServer {
26
27     private String JavaDoc keyPassword = System.getProperty( "javax.net.ssl.keyPassword" );
28     private String JavaDoc keyStorePassword = System.getProperty( "javax.net.ssl.keyStorePassword" );
29     private String JavaDoc keyStore = System.getProperty( "javax.net.ssl.keyStore" );
30     private String JavaDoc keyStoreType = null;
31     private String JavaDoc secureRandomCertficateAlgorithm = null;
32     private String JavaDoc trustCertificateAlgorithm = null;
33     private String JavaDoc keyCertificateAlgorithm = null;
34     private String JavaDoc protocol = null;
35     
36     public HttpsTransportServer( URI JavaDoc uri ) {
37         super( uri );
38     }
39
40     public void doStart() throws Exception JavaDoc {
41         SslSocketConnector sslConnector = new SslSocketConnector();
42         sslConnector.setKeystore( keyStore );
43         sslConnector.setPassword( keyStorePassword );
44         // if the keyPassword hasn't been set, default it to the
45
// key store password
46
if ( keyPassword == null ) {
47             sslConnector.setKeyPassword( keyStorePassword );
48         }
49         if ( keyStoreType != null ) {
50             sslConnector.setKeystoreType( keyStoreType );
51         }
52         if ( secureRandomCertficateAlgorithm != null ) {
53             sslConnector.setSecureRandomAlgorithm( secureRandomCertficateAlgorithm );
54         }
55         if ( keyCertificateAlgorithm != null ) {
56             sslConnector.setSslKeyManagerFactoryAlgorithm( keyCertificateAlgorithm );
57         }
58         if ( trustCertificateAlgorithm != null ) {
59             sslConnector.setSslTrustManagerFactoryAlgorithm( trustCertificateAlgorithm );
60         }
61         if ( protocol != null ) {
62             sslConnector.setProtocol( protocol );
63         }
64         
65         setConnector(sslConnector);
66         
67         super.doStart();
68     }
69     
70     // Properties
71
//--------------------------------------------------------------------------------
72

73     public String JavaDoc getKeyStore() {
74         return keyStore;
75     }
76
77     public void setKeyStore( String JavaDoc keyStore ) {
78         this.keyStore = keyStore;
79     }
80
81     public String JavaDoc getKeyPassword() {
82         return keyPassword;
83     }
84
85     public void setKeyPassword( String JavaDoc keyPassword ) {
86         this.keyPassword = keyPassword;
87     }
88
89     public String JavaDoc getKeyStoreType() {
90         return keyStoreType;
91     }
92
93     public void setKeyStoreType( String JavaDoc keyStoreType ) {
94         this.keyStoreType = keyStoreType;
95     }
96
97     public String JavaDoc getKeyStorePassword() {
98         return keyStorePassword;
99     }
100
101     public void setKeyStorePassword( String JavaDoc keyStorePassword ) {
102         this.keyStorePassword = keyStorePassword;
103     }
104
105     public String JavaDoc getProtocol() {
106         return protocol;
107     }
108
109     public void setProtocol( String JavaDoc protocol ) {
110         this.protocol = protocol;
111     }
112
113     public String JavaDoc getSecureRandomCertficateAlgorithm() {
114         return secureRandomCertficateAlgorithm;
115     }
116
117     public void setSecureRandomCertficateAlgorithm(String JavaDoc secureRandomCertficateAlgorithm) {
118         this.secureRandomCertficateAlgorithm = secureRandomCertficateAlgorithm;
119     }
120
121     public String JavaDoc getKeyCertificateAlgorithm() {
122         return keyCertificateAlgorithm;
123     }
124
125     public void setKeyCertificateAlgorithm(String JavaDoc keyCertificateAlgorithm) {
126         this.keyCertificateAlgorithm = keyCertificateAlgorithm;
127     }
128
129     public String JavaDoc getTrustCertificateAlgorithm() {
130         return trustCertificateAlgorithm;
131     }
132
133     public void setTrustCertificateAlgorithm(String JavaDoc trustCertificateAlgorithm) {
134         this.trustCertificateAlgorithm = trustCertificateAlgorithm;
135     }
136
137 }
138
Popular Tags