1 /*
2 * Copyright 1999-2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package org.apache.coyote.tomcat4;
18
19 import java.io.File;
20 import java.net.InetAddress;
21 import java.net.ServerSocket;
22
23
24 /**
25 * This socket factory holds secure socket factory parameters. Besides the usual
26 * configuration mechanism based on setting JavaBeans properties, this
27 * component may also be configured by passing a series of attributes set
28 * with calls to <code>setAttribute()</code>. The following attribute
29 * names are recognized, with default values in square brackets:
30 * <ul>
31 * <li><strong>algorithm</strong> - Certificate encoding algorithm
32 * to use. [SunX509]</li>
33 * <li><strong>clientAuth</strong> - Require client authentication if
34 * set to <code>true</code>. Want client authentication if set to
35 * <code>want</code>. (Note: Only supported in the JSSE included with
36 * J2SDK 1.4 and above. Prior versions of JSSE and PureTLS will treat
37 * 'want' as 'false'.) [false]</li>
38 * <li><strong>keystoreFile</strong> - Pathname to the Key Store file to be
39 * loaded. This must be an absolute path, or a relative path that
40 * is resolved against the "catalina.base" system property.
41 * ["./keystore" in the user home directory]</li>
42 * <li><strong>keystorePass</strong> - Password for the Key Store file to be
43 * loaded. ["changeit"]</li>
44 * <li><strong>keystoreType</strong> - Type of the Key Store file to be
45 * loaded. ["JKS"]</li>
46 * <li><strong>protocol</strong> - SSL protocol to use. [TLS]</li>
47 * </ul>
48 *
49 * @author Harish Prabandham
50 * @author Costin Manolache
51 * @author Craig McClanahan
52 */
53
54 public class CoyoteServerSocketFactory
55 implements org.apache.catalina.net.ServerSocketFactory {
56
57
58 // ------------------------------------------------------------- Properties
59
60
61 /**
62 * Certificate encoding algorithm to be used.
63 */
64 private String algorithm = null;
65
66 public String getAlgorithm() {
67 return (this.algorithm);
68 }
69
70 public void setAlgorithm(String algorithm) {
71 this.algorithm = algorithm;
72 }
73
74
75 /**
76 * Should we require client authentication?
77 */
78 private String clientAuth = "false";
79
80 public String getClientAuth() {
81 return (this.clientAuth);
82 }
83
84 public void setClientAuth(String clientAuth) {
85 this.clientAuth = clientAuth;
86 }
87
88
89 /**
90 * Pathname to the key store file to be used.
91 */
92 private String keystoreFile =
93 System.getProperty("user.home") + File.separator + ".keystore";
94
95 public String getKeystoreFile() {
96 return (this.keystoreFile);
97 }
98
99 public void setKeystoreFile(String keystoreFile) {
100
101 File file = new File(keystoreFile);
102 if (!file.isAbsolute())
103 file = new File(System.getProperty("catalina.base"),
104 keystoreFile);
105 this.keystoreFile = file.getAbsolutePath();
106 }
107
108 /**
109 * Pathname to the random file to be used.
110 */
111 private String randomFile =
112 System.getProperty("user.home") + File.separator + "random.pem";
113
114 public String getRandomFile() {
115 return (this.randomFile);
116 }
117
118 public void setRandomFile(String randomFile) {
119
120 File file = new File(randomFile);
121 if (!file.isAbsolute())
122 file = new File(System.getProperty("catalina.base"),
123 randomFile);
124 this.randomFile = file.getAbsolutePath();
125 }
126
127 /**
128 * Pathname to the root list to be used.
129 */
130 private String rootFile =
131 System.getProperty("user.home") + File.separator + "root.pem";
132
133 public String getRootFile() {
134 return (this.rootFile);
135 }
136
137 public void setRootFile(String rootFile) {
138
139 File file = new File(rootFile);
140 if (!file.isAbsolute())
141 file = new File(System.getProperty("catalina.base"),
142 rootFile);
143 this.rootFile = file.getAbsolutePath();
144 }
145
146 /**
147 * Password for accessing the key store file.
148 */
149 private String keystorePass = "changeit";
150
151 public String getKeystorePass() {
152 return (this.keystorePass);
153 }
154
155 public void setKeystorePass(String keystorePass) {
156 this.keystorePass = keystorePass;
157 }
158
159
160 /**
161 * Storeage type of the key store file to be used.
162 */
163 private String keystoreType = "JKS";
164
165 public String getKeystoreType() {
166 return (this.keystoreType);
167 }
168
169 public void setKeystoreType(String keystoreType) {
170 this.keystoreType = keystoreType;
171 }
172
173
174 /**
175 * SSL protocol variant to use.
176 */
177 private String protocol = "TLS";
178
179 public String getProtocol() {
180 return (this.protocol);
181 }
182
183 public void setProtocol(String protocol) {
184 this.protocol = protocol;
185 }
186
187
188 /**
189 * SSL implementation to use.
190 */
191 private String sslImplementation = null;
192
193 public String getSSLImplementation() {
194 return (this.sslImplementation);
195 }
196
197 public void setSSLImplementation(String sslImplementation) {
198 this.sslImplementation = sslImplementation;
199 }
200
201
202
203 // --------------------------------------------------------- Public Methods
204
205
206 public ServerSocket createSocket(int port) {
207 return (null);
208 }
209
210
211 public ServerSocket createSocket(int port, int backlog) {
212 return (null);
213 }
214
215
216 public ServerSocket createSocket(int port, int backlog,
217 InetAddress ifAddress) {
218 return (null);
219 }
220
221
222 }