001    package org.ujmp.core.util;
002    
003    import java.io.IOException;
004    import java.net.InetAddress;
005    import java.net.Socket;
006    
007    import javax.net.SocketFactory;
008    import javax.net.ssl.SSLContext;
009    import javax.net.ssl.SSLSocketFactory;
010    import javax.net.ssl.TrustManager;
011    
012    public class DummySSLSocketFactory extends SSLSocketFactory {
013            private SSLSocketFactory factory;
014    
015            public DummySSLSocketFactory() {
016                    try {
017                            SSLContext sslcontext = SSLContext.getInstance("SSL");
018                            sslcontext.init(
019                                            null, // No KeyManager required
020                                            new TrustManager[] { new DummyTrustManager() },
021                                            new java.security.SecureRandom());
022                            factory = (SSLSocketFactory) sslcontext.getSocketFactory();
023                    } catch (Exception ex) {
024                            ex.printStackTrace();
025                    }
026            }
027    
028            public static SocketFactory getDefault() {
029                    return new DummySSLSocketFactory();
030            }
031    
032            public Socket createSocket(Socket socket, String s, int i, boolean flag) throws IOException {
033                    return factory.createSocket(socket, s, i, flag);
034            }
035    
036            public Socket createSocket(InetAddress inaddr, int i, InetAddress inaddr1, int j)
037                            throws IOException {
038                    return factory.createSocket(inaddr, i, inaddr1, j);
039            }
040    
041            public Socket createSocket(InetAddress inaddr, int i) throws IOException {
042                    return factory.createSocket(inaddr, i);
043            }
044    
045            public Socket createSocket(String s, int i, InetAddress inaddr, int j) throws IOException {
046                    return factory.createSocket(s, i, inaddr, j);
047            }
048    
049            public Socket createSocket(String s, int i) throws IOException {
050                    return factory.createSocket(s, i);
051            }
052    
053            public String[] getDefaultCipherSuites() {
054                    return factory.getSupportedCipherSuites();
055            }
056    
057            public String[] getSupportedCipherSuites() {
058                    return factory.getSupportedCipherSuites();
059            }
060    }