01: /*
02: * Copyright 1999-2004 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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.tomcat.util.net.jsse;
18:
19: import java.net.Socket;
20:
21: import org.apache.tomcat.util.compat.JdkCompat;
22: import org.apache.tomcat.util.net.SSLImplementation;
23: import org.apache.tomcat.util.net.SSLSupport;
24: import org.apache.tomcat.util.net.ServerSocketFactory;
25:
26: /* JSSEImplementation:
27:
28: Concrete implementation class for JSSE
29:
30: @author EKR
31: */
32:
33: public class JSSEImplementation extends SSLImplementation {
34: static final String JSSE14Factory = "org.apache.tomcat.util.net.jsse.JSSE14Factory";
35: static final String JSSE13Factory = "org.apache.tomcat.util.net.jsse.JSSE13Support";
36: static final String SSLSocketClass = "javax.net.ssl.SSLSocket";
37:
38: static org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory
39: .getLog(JSSEImplementation.class);
40:
41: private JSSEFactory factory;
42:
43: public JSSEImplementation() throws ClassNotFoundException {
44: // Check to see if JSSE is floating around somewhere
45: Class.forName(SSLSocketClass);
46: if (JdkCompat.isJava14()) {
47: try {
48: Class factcl = Class.forName(JSSE14Factory);
49: factory = (JSSEFactory) factcl.newInstance();
50: } catch (Exception ex) {
51: factory = new JSSE13Factory();
52: if (logger.isDebugEnabled()) {
53: logger.debug("Error getting factory: "
54: + JSSE14Factory, ex);
55: }
56: }
57: } else {
58: factory = new JSSE13Factory();
59: }
60: }
61:
62: public String getImplementationName() {
63: return "JSSE";
64: }
65:
66: public ServerSocketFactory getServerSocketFactory() {
67: ServerSocketFactory ssf = factory.getSocketFactory();
68: return ssf;
69: }
70:
71: public SSLSupport getSSLSupport(Socket s) {
72: SSLSupport ssls = factory.getSSLSupport(s);
73: return ssls;
74: }
75: }
|