@@ -0,0 +1,3162 @@
+/*%0A *  Licensed to the Apache Software Foundation (ASF) under one or more%0A *  contributor license agreements.  See the NOTICE file distributed with%0A *  this work for additional information regarding copyright ownership.%0A *  The ASF licenses this file to You under the Apache License, Version 2.0%0A *  (the %22License%22); you may not use this file except in compliance with%0A *  the License.  You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A *  Unless required by applicable law or agreed to in writing, software%0A *  distributed under the License is distributed on an %22AS IS%22 BASIS,%0A *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A *  See the License for the specific language governing permissions and%0A *  limitations under the License.%0A */%0A%0A/**%0A* @author Boris V. Kuznetsov%0A* @version $Revision$%0A*/%0A%0Apackage javax.net.ssl;%0A%0Aimport java.io.IOException;%0Aimport java.net.Socket;%0Aimport java.security.AccessController;%0Aimport java.security.PrivilegedAction;%0Aimport java.security.Security;%0A%0Aimport javax.net.SocketFactory;%0A%0Apublic abstract class SSLSocketFactory extends SocketFactory %7B%0A    // FIXME EXPORT CONTROL%0A%0A    // The default SSL socket factory%0A    private static SocketFactory defaultSocketFactory;%0A%0A    private static String defaultName;%0A%0A    public static synchronized SocketFactory getDefault() %7B%0A        if (defaultSocketFactory != null) %7B%0A            return defaultSocketFactory;%0A        %7D%0A        if (defaultName == null) %7B%0A            AccessController.doPrivileged(new PrivilegedAction%3CVoid%3E() %7B%0A                public Void run() %7B%0A                    defaultName = Security.getProperty(%22ssl.SocketFactory.provider%22);%0A                    if (defaultName != null) %7B%0A                        ClassLoader cl = Thread.currentThread().getContextClassLoader();%0A                        if (cl == null) %7B%0A                            cl = ClassLoader.getSystemClassLoader();%0A                        %7D%0A                        try %7B%0A                            final Class%3C?%3E sfc = Class.forName(defaultName, true, cl);%0A                            defaultSocketFactory = (SocketFactory) sfc.newInstance();%0A                        %7D catch (Exception e) %7B%0A                        %7D%0A                    %7D%0A                    return null;%0A                %7D%0A            %7D);%0A        %7D%0A%0A        if (defaultSocketFactory == null) %7B%0A            // Try to find in providers%0A            SSLContext context = DefaultSSLContext.getContext();%0A            if (context != null) %7B%0A                defaultSocketFactory = context.getSocketFactory();%0A            %7D%0A        %7D%0A        if (defaultSocketFactory == null) %7B%0A            // Use internal implementation%0A            defaultSocketFactory = new DefaultSSLSocketFactory(%22No SSLSocketFactory installed%22);%0A        %7D%0A        return defaultSocketFactory;%0A    %7D%0A%0A    public SSLSocketFactory() %7B%0A        super();%0A    %7D%0A%0A    public abstract String%5B%5D getDefaultCipherSuites();%0A%0A    public abstract String%5B%5D getSupportedCipherSuites();%0A%0A    public abstract Socket createSocket(Socket s, String host, int port, boolean autoClose)%0A            throws IOException;%0A%7D%0A

add synchronized keyword to keep thread-safe; general clean up of code