01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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:
18: /**
19: * @author Boris V. Kuznetsov
20: * @version $Revision$
21: */package javax.net.ssl;
22:
23: import java.io.IOException;
24: import java.net.Socket;
25: import java.security.AccessController;
26: import java.security.Security;
27:
28: import javax.net.SocketFactory;
29:
30: /**
31: * @com.intel.drl.spec_ref
32: *
33: */
34: public abstract class SSLSocketFactory extends SocketFactory {
35: // FIXME EXPORT CONTROL
36:
37: // The default SSL socket factory
38: private static SocketFactory defaultSocketFactory;
39:
40: private static String defaultName;
41:
42: public SSLSocketFactory() {
43: super ();
44: }
45:
46: public static SocketFactory getDefault() {
47: if (defaultSocketFactory != null) {
48: return defaultSocketFactory;
49: }
50: if (defaultName == null) {
51: AccessController
52: .doPrivileged(new java.security.PrivilegedAction() {
53: public Object run() {
54: defaultName = Security
55: .getProperty("ssl.SocketFactory.provider");
56: if (defaultName != null) {
57: ClassLoader cl = Thread.currentThread()
58: .getContextClassLoader();
59: if (cl == null) {
60: cl = ClassLoader
61: .getSystemClassLoader();
62: }
63: try {
64: defaultSocketFactory = (SocketFactory) Class
65: .forName(defaultName, true,
66: cl).newInstance();
67: } catch (Exception e) {
68: return e;
69: }
70: }
71: return null;
72: }
73: });
74: }
75:
76: if (defaultSocketFactory == null) {
77: // Try to find in providers
78: SSLContext context = DefaultSSLContext.getContext();
79: if (context != null) {
80: defaultSocketFactory = context.getSocketFactory();
81: }
82: }
83: if (defaultSocketFactory == null) {
84: // Use internal implementation
85: defaultSocketFactory = new DefaultSSLSocketFactory(
86: "No SSLSocketFactory installed");
87: }
88: return defaultSocketFactory;
89: }
90:
91: public abstract String[] getDefaultCipherSuites();
92:
93: public abstract String[] getSupportedCipherSuites();
94:
95: public abstract Socket createSocket(Socket s, String host,
96: int port, boolean autoClose) throws IOException;
97:
98: }
|