KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > http > SslParameters


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

17 package org.apache.servicemix.http;
18
19 /**
20  * This class contains all parameters needed to create an SSL server or client
21  * socket.
22  *
23  * @author gnodet
24  * @org.apache.xbean.XBean
25  */

26 public class SslParameters {
27
28     private boolean managed;
29     private String JavaDoc keyAlias;
30     private String JavaDoc keyPassword;
31     private String JavaDoc keyStore;
32     private String JavaDoc keyStorePassword;
33     private String JavaDoc keyStoreType = "JKS"; // type of the key store
34
private String JavaDoc trustStore;
35     private String JavaDoc trustStorePassword;
36     private String JavaDoc trustStoreType = "JKS";
37     private String JavaDoc protocol = "TLS";
38     private String JavaDoc keyManagerFactoryAlgorithm = "SunX509"; // cert algorithm
39
private String JavaDoc trustManagerFactoryAlgorithm = "SunX509"; // cert algorithm
40
private String JavaDoc provider = null;
41     private boolean wantClientAuth = false;
42     private boolean needClientAuth = false;
43     
44     /**
45      * @return the provider
46      */

47     public String JavaDoc getProvider() {
48         return provider;
49     }
50     /**
51      * @param provider the provider to set
52      */

53     public void setProvider(String JavaDoc provider) {
54         this.provider = provider;
55     }
56     /**
57      * @return the managed
58      */

59     public boolean isManaged() {
60         return managed;
61     }
62     /**
63      * @param managed the managed to set
64      */

65     public void setManaged(boolean managed) {
66         this.managed = managed;
67     }
68     /**
69      * @return the keyAlias
70      */

71     public String JavaDoc getKeyAlias() {
72         return keyAlias;
73     }
74     /**
75      * @param keyAlias the keyAlias to set
76      */

77     public void setKeyAlias(String JavaDoc keyAlias) {
78         this.keyAlias = keyAlias;
79     }
80     /**
81      * @return Returns the algorithm.
82      */

83     public String JavaDoc getKeyManagerFactoryAlgorithm() {
84         return keyManagerFactoryAlgorithm;
85     }
86     /**
87      * @param algorithm The algorithm to set.
88      */

89     public void setKeyManagerFactoryAlgorithm(String JavaDoc algorithm) {
90         this.keyManagerFactoryAlgorithm = algorithm;
91     }
92     /**
93      * @return Returns the algorithm.
94      */

95     public String JavaDoc getTrustManagerFactoryAlgorithm() {
96         return trustManagerFactoryAlgorithm;
97     }
98     /**
99      * @param algorithm The algorithm to set.
100      */

101     public void setTrustManagerFactoryAlgorithm(String JavaDoc algorithm) {
102         this.trustManagerFactoryAlgorithm = algorithm;
103     }
104     /**
105      * @return Returns the keyPassword.
106      */

107     public String JavaDoc getKeyPassword() {
108         return keyPassword;
109     }
110     /**
111      * @param keyPassword The keyPassword to set.
112      */

113     public void setKeyPassword(String JavaDoc keyPassword) {
114         this.keyPassword = keyPassword;
115     }
116     /**
117      * @return Returns the keyStore.
118      */

119     public String JavaDoc getKeyStore() {
120         return keyStore;
121     }
122     /**
123      * @param keyStore The keyStore to set.
124      */

125     public void setKeyStore(String JavaDoc keyStore) {
126         this.keyStore = keyStore;
127     }
128     /**
129      * @return Returns the keyStorePassword.
130      */

131     public String JavaDoc getKeyStorePassword() {
132         return keyStorePassword;
133     }
134     /**
135      * @param keyStorePassword The keyStorePassword to set.
136      */

137     public void setKeyStorePassword(String JavaDoc keyStorePassword) {
138         this.keyStorePassword = keyStorePassword;
139     }
140     /**
141      * @return Returns the keyStoreType.
142      */

143     public String JavaDoc getKeyStoreType() {
144         return keyStoreType;
145     }
146     /**
147      * @param keyStoreType The keyStoreType to set.
148      */

149     public void setKeyStoreType(String JavaDoc keyStoreType) {
150         this.keyStoreType = keyStoreType;
151     }
152     /**
153      * @return Returns the needClientAuth.
154      */

155     public boolean isNeedClientAuth() {
156         return needClientAuth;
157     }
158     /**
159      * @param needClientAuth The needClientAuth to set.
160      */

161     public void setNeedClientAuth(boolean needClientAuth) {
162         this.needClientAuth = needClientAuth;
163     }
164     /**
165      * @return Returns the protocol.
166      */

167     public String JavaDoc getProtocol() {
168         return protocol;
169     }
170     /**
171      * @param protocol The protocol to set.
172      */

173     public void setProtocol(String JavaDoc protocol) {
174         this.protocol = protocol;
175     }
176     /**
177      * @return Returns the wantClientAuth.
178      */

179     public boolean isWantClientAuth() {
180         return wantClientAuth;
181     }
182     /**
183      * @param wantClientAuth The wantClientAuth to set.
184      */

185     public void setWantClientAuth(boolean wantClientAuth) {
186         this.wantClientAuth = wantClientAuth;
187     }
188     /**
189      * @return Returns the trustStore.
190      */

191     public String JavaDoc getTrustStore() {
192         return trustStore;
193     }
194     /**
195      * @param trustStore The trustStore to set.
196      */

197     public void setTrustStore(String JavaDoc trustStore) {
198         this.trustStore = trustStore;
199     }
200     /**
201      * @return Returns the trustStorePassword.
202      */

203     public String JavaDoc getTrustStorePassword() {
204         return trustStorePassword;
205     }
206     /**
207      * @param trustStorePassword The trustStorePassword to set.
208      */

209     public void setTrustStorePassword(String JavaDoc trustStorePassword) {
210         this.trustStorePassword = trustStorePassword;
211     }
212     /**
213      * @return Returns the trustStoreType.
214      */

215     public String JavaDoc getTrustStoreType() {
216         return trustStoreType;
217     }
218     /**
219      * @param trustStoreType The trustStoreType to set.
220      */

221     public void setTrustStoreType(String JavaDoc trustStoreType) {
222         this.trustStoreType = trustStoreType;
223     }
224     
225     public boolean equals(Object JavaDoc o) {
226         if (o == this) {
227             return true;
228         }
229         if (o instanceof SslParameters == false) {
230             return false;
231         }
232         SslParameters s = (SslParameters) o;
233         return managed == s.managed &&
234                eq(keyAlias, s.keyAlias) &&
235                eq(keyManagerFactoryAlgorithm, s.keyManagerFactoryAlgorithm) &&
236                eq(trustManagerFactoryAlgorithm, s.trustManagerFactoryAlgorithm) &&
237                eq(keyPassword, s.keyPassword) &&
238                eq(keyStore, s.keyStore) &&
239                eq(keyStorePassword, s.keyStorePassword) &&
240                eq(keyStoreType, s.keyStoreType) &&
241                needClientAuth == s.needClientAuth &&
242                eq(protocol, s.protocol) &&
243                eq(trustStore, s.trustStore) &&
244                eq(trustStorePassword, s.trustStorePassword) &&
245                eq(trustStoreType, s.trustStoreType) &&
246                wantClientAuth == s.wantClientAuth;
247                
248     }
249     
250     public int hashCode() {
251         return Boolean.valueOf(managed).hashCode() ^
252                hash(keyAlias) ^
253                hash(keyManagerFactoryAlgorithm) ^
254                hash(trustManagerFactoryAlgorithm) ^
255                hash(keyPassword) ^
256                hash(keyStore) ^
257                hash(keyStorePassword) ^
258                hash(keyStoreType) ^
259                Boolean.valueOf(needClientAuth).hashCode() ^
260                hash(protocol) ^
261                hash(trustStore) ^
262                hash(trustStorePassword) ^
263                hash(trustStoreType) ^
264                Boolean.valueOf(wantClientAuth).hashCode();
265     }
266     
267     private static boolean eq(String JavaDoc s1, String JavaDoc s2) {
268         return (s1 == null) ? s2 == null : s1.equals(s2);
269     }
270     
271     private static int hash(String JavaDoc s) {
272         return s != null ? s.hashCode() : 0;
273     }
274
275
276 }
277
Popular Tags