001: /*
002: * Copyright 1999-2004 The Apache Software Foundation
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.apache.coyote.tomcat4;
018:
019: import java.io.File;
020: import java.net.InetAddress;
021: import java.net.ServerSocket;
022:
023: /**
024: * This socket factory holds secure socket factory parameters. Besides the usual
025: * configuration mechanism based on setting JavaBeans properties, this
026: * component may also be configured by passing a series of attributes set
027: * with calls to <code>setAttribute()</code>. The following attribute
028: * names are recognized, with default values in square brackets:
029: * <ul>
030: * <li><strong>algorithm</strong> - Certificate encoding algorithm
031: * to use. [SunX509]</li>
032: * <li><strong>clientAuth</strong> - Require client authentication if
033: * set to <code>true</code>. Want client authentication if set to
034: * <code>want</code>. (Note: Only supported in the JSSE included with
035: * J2SDK 1.4 and above. Prior versions of JSSE and PureTLS will treat
036: * 'want' as 'false'.) [false]</li>
037: * <li><strong>keystoreFile</strong> - Pathname to the Key Store file to be
038: * loaded. This must be an absolute path, or a relative path that
039: * is resolved against the "catalina.base" system property.
040: * ["./keystore" in the user home directory]</li>
041: * <li><strong>keystorePass</strong> - Password for the Key Store file to be
042: * loaded. ["changeit"]</li>
043: * <li><strong>keystoreType</strong> - Type of the Key Store file to be
044: * loaded. ["JKS"]</li>
045: * <li><strong>protocol</strong> - SSL protocol to use. [TLS]</li>
046: * </ul>
047: *
048: * @author Harish Prabandham
049: * @author Costin Manolache
050: * @author Craig McClanahan
051: */
052:
053: public class CoyoteServerSocketFactory implements
054: org.apache.catalina.net.ServerSocketFactory {
055:
056: // ------------------------------------------------------------- Properties
057:
058: /**
059: * Certificate encoding algorithm to be used.
060: */
061: private String algorithm = null;
062:
063: public String getAlgorithm() {
064: return (this .algorithm);
065: }
066:
067: public void setAlgorithm(String algorithm) {
068: this .algorithm = algorithm;
069: }
070:
071: /**
072: * Should we require client authentication?
073: */
074: private String clientAuth = "false";
075:
076: public String getClientAuth() {
077: return (this .clientAuth);
078: }
079:
080: public void setClientAuth(String clientAuth) {
081: this .clientAuth = clientAuth;
082: }
083:
084: /**
085: * Pathname to the key store file to be used.
086: */
087: private String keystoreFile = System.getProperty("user.home")
088: + File.separator + ".keystore";
089:
090: public String getKeystoreFile() {
091: return (this .keystoreFile);
092: }
093:
094: public void setKeystoreFile(String keystoreFile) {
095:
096: File file = new File(keystoreFile);
097: if (!file.isAbsolute())
098: file = new File(System.getProperty("catalina.base"),
099: keystoreFile);
100: this .keystoreFile = file.getAbsolutePath();
101: }
102:
103: /**
104: * Pathname to the random file to be used.
105: */
106: private String randomFile = System.getProperty("user.home")
107: + File.separator + "random.pem";
108:
109: public String getRandomFile() {
110: return (this .randomFile);
111: }
112:
113: public void setRandomFile(String randomFile) {
114:
115: File file = new File(randomFile);
116: if (!file.isAbsolute())
117: file = new File(System.getProperty("catalina.base"),
118: randomFile);
119: this .randomFile = file.getAbsolutePath();
120: }
121:
122: /**
123: * Pathname to the root list to be used.
124: */
125: private String rootFile = System.getProperty("user.home")
126: + File.separator + "root.pem";
127:
128: public String getRootFile() {
129: return (this .rootFile);
130: }
131:
132: public void setRootFile(String rootFile) {
133:
134: File file = new File(rootFile);
135: if (!file.isAbsolute())
136: file = new File(System.getProperty("catalina.base"),
137: rootFile);
138: this .rootFile = file.getAbsolutePath();
139: }
140:
141: /**
142: * Password for accessing the key store file.
143: */
144: private String keystorePass = "changeit";
145:
146: public String getKeystorePass() {
147: return (this .keystorePass);
148: }
149:
150: public void setKeystorePass(String keystorePass) {
151: this .keystorePass = keystorePass;
152: }
153:
154: /**
155: * Storeage type of the key store file to be used.
156: */
157: private String keystoreType = "JKS";
158:
159: public String getKeystoreType() {
160: return (this .keystoreType);
161: }
162:
163: public void setKeystoreType(String keystoreType) {
164: this .keystoreType = keystoreType;
165: }
166:
167: /**
168: * SSL protocol variant to use.
169: */
170: private String protocol = "TLS";
171:
172: public String getProtocol() {
173: return (this .protocol);
174: }
175:
176: public void setProtocol(String protocol) {
177: this .protocol = protocol;
178: }
179:
180: /**
181: * SSL implementation to use.
182: */
183: private String sslImplementation = null;
184:
185: public String getSSLImplementation() {
186: return (this .sslImplementation);
187: }
188:
189: public void setSSLImplementation(String sslImplementation) {
190: this .sslImplementation = sslImplementation;
191: }
192:
193: // --------------------------------------------------------- Public Methods
194:
195: public ServerSocket createSocket(int port) {
196: return (null);
197: }
198:
199: public ServerSocket createSocket(int port, int backlog) {
200: return (null);
201: }
202:
203: public ServerSocket createSocket(int port, int backlog,
204: InetAddress ifAddress) {
205: return (null);
206: }
207:
208: }
|