KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > coyote > tomcat5 > CoyoteServerSocketFactory


1
2
3 /*
4  * The contents of this file are subject to the terms
5  * of the Common Development and Distribution License
6  * (the "License"). You may not use this file except
7  * in compliance with the License.
8  *
9  * You can obtain a copy of the license at
10  * glassfish/bootstrap/legal/CDDLv1.0.txt or
11  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
12  * See the License for the specific language governing
13  * permissions and limitations under the License.
14  *
15  * When distributing Covered Code, include this CDDL
16  * HEADER in each file and include the License file at
17  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
18  * add the following below this CDDL HEADER, with the
19  * fields enclosed by brackets "[]" replaced with your
20  * own identifying information: Portions Copyright [yyyy]
21  * [name of copyright owner]
22  *
23  * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24  *
25  * Portions Copyright Apache Software Foundation.
26  */

27 package org.apache.coyote.tomcat5;
28
29 import java.io.File JavaDoc;
30 import java.io.FileInputStream JavaDoc;
31 import java.io.IOException JavaDoc;
32 import java.net.InetAddress JavaDoc;
33 import java.net.ServerSocket JavaDoc;
34 import java.security.KeyStore JavaDoc;
35 import java.security.KeyStoreException JavaDoc;
36 import java.security.NoSuchAlgorithmException JavaDoc;
37 import java.security.UnrecoverableKeyException JavaDoc;
38 import java.security.KeyManagementException JavaDoc;
39 import java.security.Security JavaDoc;
40 import java.security.cert.CertificateException JavaDoc;
41
42
43 /**
44  * This socket factory holds secure socket factory parameters. Besides the usual
45  * configuration mechanism based on setting JavaBeans properties, this
46  * component may also be configured by passing a series of attributes set
47  * with calls to <code>setAttribute()</code>. The following attribute
48  * names are recognized, with default values in square brackets:
49  * <ul>
50  * <li><strong>algorithm</strong> - Certificate encoding algorithm
51  * to use. [SunX509]</li>
52  * <li><strong>clientAuth</strong> - Require client authentication if
53  * set to <code>true</code>. [false]</li>
54  * <li><strong>keystoreFile</strong> - Pathname to the Key Store file to be
55  * loaded. This must be an absolute path, or a relative path that
56  * is resolved against the "catalina.base" system property.
57  * ["./keystore" in the user home directory]</li>
58  * <li><strong>keystorePass</strong> - Password for the Key Store file to be
59  * loaded. ["changeit"]</li>
60  * <li><strong>keystoreType</strong> - Type of the Key Store file to be
61  * loaded. ["JKS"]</li>
62  * <li><strong>protocol</strong> - SSL protocol to use. [TLS]</li>
63  * </ul>
64  *
65  * @author Harish Prabandham
66  * @author Costin Manolache
67  * @author Craig McClanahan
68  */

69
70 public class CoyoteServerSocketFactory
71     implements org.apache.catalina.net.ServerSocketFactory {
72
73     private String JavaDoc algorithm = null;
74     private boolean clientAuth = false;
75     private String JavaDoc keystoreFile =
76         System.getProperty("user.home") + File.separator + ".keystore";
77     private String JavaDoc randomFile =
78         System.getProperty("user.home") + File.separator + "random.pem";
79     private String JavaDoc rootFile =
80         System.getProperty("user.home") + File.separator + "root.pem";
81     private String JavaDoc keystorePass = "changeit";
82     private String JavaDoc keystoreType = "JKS";
83     private String JavaDoc protocol = "TLS";
84     private String JavaDoc protocols;
85     private String JavaDoc sslImplementation = null;
86     private String JavaDoc cipherSuites;
87     private String JavaDoc keyAlias;
88
89     // ------------------------------------------------------------- Properties
90

91     /**
92      * Gets the certificate encoding algorithm to be used.
93      *
94      * @return Certificate encoding algorithm
95      */

96     public String JavaDoc getAlgorithm() {
97         return (this.algorithm);
98     }
99
100     /**
101      * Sets the certificate encoding algorithm to be used.
102      *
103      * @param algorithm Certificate encoding algorithm
104      */

105     public void setAlgorithm(String JavaDoc algorithm) {
106         this.algorithm = algorithm;
107     }
108
109     /**
110      * Provides information about whether client authentication is enforced.
111      *
112      * @return true if client authentication is enforced, false otherwise
113      */

114     public boolean getClientAuth() {
115         return (this.clientAuth);
116     }
117
118     /**
119      * Sets the requirement of client authentication.
120      *
121      * @param clientAuth true if client authentication is enforced, false
122      * otherwise
123      */

124     public void setClientAuth(boolean clientAuth) {
125         this.clientAuth = clientAuth;
126     }
127
128     /**
129      * Gets the pathname to the keystore file.
130      *
131      * @return Pathname to the keystore file
132      */

133     public String JavaDoc getKeystoreFile() {
134         return (this.keystoreFile);
135     }
136
137     /**
138      * Sets the pathname to the keystore file.
139      *
140      * @param keystoreFile Pathname to the keystore file
141      */

142     public void setKeystoreFile(String JavaDoc keystoreFile) {
143       
144         File JavaDoc file = new File JavaDoc(keystoreFile);
145         if (!file.isAbsolute())
146             file = new File JavaDoc(System.getProperty("catalina.base"),
147                             keystoreFile);
148         this.keystoreFile = file.getAbsolutePath();
149     }
150
151     /**
152      * Gets the pathname to the random file.
153      *
154      * @return Pathname to the random file
155      */

156     public String JavaDoc getRandomFile() {
157         return (this.randomFile);
158     }
159
160     /**
161      * Sets the pathname to the random file.
162      *
163      * @param randomFile Pathname to the random file
164      */

165     public void setRandomFile(String JavaDoc randomFile) {
166       
167         File JavaDoc file = new File JavaDoc(randomFile);
168         if (!file.isAbsolute())
169             file = new File JavaDoc(System.getProperty("catalina.base"),
170                             randomFile);
171         this.randomFile = file.getAbsolutePath();
172     }
173
174     /**
175      * Gets the pathname to the root list.
176      *
177      * @return Pathname to the root list
178      */

179     public String JavaDoc getRootFile() {
180         return (this.rootFile);
181     }
182
183     /**
184      * Sets the pathname to the root list.
185      *
186      * @param rootFile Pathname to the root list
187      */

188     public void setRootFile(String JavaDoc rootFile) {
189       
190         File JavaDoc file = new File JavaDoc(rootFile);
191         if (!file.isAbsolute())
192             file = new File JavaDoc(System.getProperty("catalina.base"),
193                             rootFile);
194         this.rootFile = file.getAbsolutePath();
195     }
196      
197     /**
198      * Gets the keystore password.
199      *
200      * @return Keystore password
201      */

202     public String JavaDoc getKeystorePass() {
203         return (this.keystorePass);
204     }
205
206     /**
207      * Sets the keystore password.
208      *
209      * @param keystorePass Keystore password
210      */

211     public void setKeystorePass(String JavaDoc keystorePass) {
212         this.keystorePass = keystorePass;
213     }
214
215     /**
216      * Gets the keystore type.
217      *
218      * @return Keystore type
219      */

220     public String JavaDoc getKeystoreType() {
221         return (this.keystoreType);
222     }
223
224     /**
225      * Sets the keystore type.
226      *
227      * @param keystoreType Keystore type
228      */

229     public void setKeystoreType(String JavaDoc keystoreType) {
230         this.keystoreType = keystoreType;
231     }
232
233     /**
234      * Gets the SSL protocol variant to be used.
235      *
236      * @return SSL protocol variant
237      */

238     public String JavaDoc getProtocol() {
239         return (this.protocol);
240     }
241
242     /**
243      * Sets the SSL protocol variant to be used.
244      *
245      * @param protocol SSL protocol variant
246      */

247     public void setProtocol(String JavaDoc protocol) {
248         this.protocol = protocol;
249     }
250
251     /**
252      * Gets the SSL protocol variants to be enabled.
253      *
254      * @return Comma-separated list of SSL protocol variants
255      */

256     public String JavaDoc getProtocols() {
257         return this.protocols;
258     }
259
260     /**
261      * Sets the SSL protocol variants to be enabled.
262      *
263      * @param protocols Comma-separated list of SSL protocol variants
264      */

265     public void setProtocols(String JavaDoc protocols) {
266         this.protocols = protocols;
267     }
268
269     /**
270      * Gets the name of the SSL implementation to be used.
271      *
272      * @return SSL implementation name
273      */

274     public String JavaDoc getSSLImplementation() {
275         return (this.sslImplementation);
276     }
277
278     /**
279      * Sets the name of the SSL implementation to be used.
280      *
281      * @param sslImplementation SSL implementation name
282      */

283     public void setSSLImplementation(String JavaDoc sslImplementation) {
284         this.sslImplementation = sslImplementation;
285     }
286
287     /**
288      * Gets the alias name of the keypair and supporting certificate chain
289      * used by the server to authenticate itself to SSL clients.
290      *
291      * @return The alias name of the keypair and supporting certificate chain
292      */

293     public String JavaDoc getKeyAlias() {
294         return this.keyAlias;
295     }
296
297     /**
298      * Sets the alias name of the keypair and supporting certificate chain
299      * used by the server to authenticate itself to SSL clients.
300      *
301      * @param alias The alias name of the keypair and supporting certificate
302      * chain
303      */

304     public void setKeyAlias(String JavaDoc alias) {
305         this.keyAlias = alias;
306     }
307
308     /**
309      * Gets the list of SSL cipher suites that are to be enabled
310      *
311      * @return Comma-separated list of SSL cipher suites, or null if all
312      * cipher suites supported by the underlying SSL implementation are being
313      * enabled
314      */

315     public String JavaDoc getCiphers() {
316     return this.cipherSuites;
317     }
318
319     /**
320      * Sets the SSL cipher suites that are to be enabled.
321      *
322      * Only those SSL cipher suites that are actually supported by
323      * the underlying SSL implementation will be enabled.
324      *
325      * @param ciphers Comma-separated list of SSL cipher suites
326      */

327     public void setCiphers(String JavaDoc ciphers) {
328     this.cipherSuites = ciphers;
329     }
330
331
332     // --------------------------------------------------------- Public Methods
333

334
335     public ServerSocket JavaDoc createSocket(int port) {
336         return (null);
337     }
338
339
340     public ServerSocket JavaDoc createSocket(int port, int backlog) {
341         return (null);
342     }
343
344
345     public ServerSocket JavaDoc createSocket(int port, int backlog,
346                                      InetAddress JavaDoc ifAddress) {
347         return (null);
348     }
349
350
351 }
352
Popular Tags