SSLServerSocketFactory.java revision 2ad60cfc28e14ee8f0bb038720836a4696c478ad
1/* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * 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*/ 22 23package javax.net.ssl; 24 25import java.security.AccessController; 26import java.security.Security; 27 28import javax.net.ServerSocketFactory; 29 30/** 31 * @com.intel.drl.spec_ref 32 * 33 */ 34public abstract class SSLServerSocketFactory extends ServerSocketFactory { 35// TODO EXPORT CONTROL 36 37 // The default SSL socket factory 38 private static ServerSocketFactory defaultServerSocketFactory; 39 40 private static String defaultName; 41 42 protected SSLServerSocketFactory() { 43 super(); 44 } 45 46 public static ServerSocketFactory getDefault() { 47 if (defaultServerSocketFactory != null) { 48 return defaultServerSocketFactory; 49 } 50 if (defaultName == null) { 51 AccessController.doPrivileged(new java.security.PrivilegedAction(){ 52 public Object run() { 53 defaultName = Security.getProperty("ssl.ServerSocketFactory.provider"); 54 if (defaultName != null) { 55 ClassLoader cl = Thread.currentThread().getContextClassLoader(); 56 if (cl == null) { 57 cl = ClassLoader.getSystemClassLoader(); 58 } 59 try { 60 defaultServerSocketFactory = (ServerSocketFactory) Class 61 .forName(defaultName, true, cl) 62 .newInstance(); 63 } catch (Exception e) { 64 return e; 65 } 66 } 67 return null; 68 } 69 }); 70 } 71 if (defaultServerSocketFactory == null) { 72 // Try to find in providers 73 SSLContext context = DefaultSSLContext.getContext(); 74 if (context != null) { 75 defaultServerSocketFactory = context.getServerSocketFactory(); 76 } 77 } 78 if (defaultServerSocketFactory == null) { 79 // Use internal dummy implementation 80 defaultServerSocketFactory = new DefaultSSLServerSocketFactory("No ServerSocketFactory installed"); 81 } 82 return defaultServerSocketFactory; 83 } 84 85 public abstract String[] getDefaultCipherSuites(); 86 public abstract String[] getSupportedCipherSuites(); 87 88} 89