1 56 package org.opencrx.ssl; 57 58 import java.io.IOException ; 59 import java.net.InetAddress ; 60 import java.net.Socket ; 61 62 import javax.net.SocketFactory; 63 import javax.net.ssl.SSLContext; 64 import javax.net.ssl.SSLSocketFactory; 65 import javax.net.ssl.TrustManager; 66 67 public class DefaultSSLSocketFactory 68 extends SSLSocketFactory { 69 70 SSLSocketFactory factory; 71 72 public DefaultSSLSocketFactory( 73 ) { 74 try { 75 SSLContext sslContext = SSLContext.getInstance( 76 "TLS" 77 ); 78 sslContext.init( 79 null, new TrustManager[] {new DefaultTrustManager()}, 81 new java.security.SecureRandom () 82 ); 83 factory = sslContext.getSocketFactory(); 84 } 85 catch(Exception e) { 86 e.printStackTrace(); 87 } 88 } 89 90 public static SocketFactory getDefault() { 91 return new DefaultSSLSocketFactory(); 92 } 93 94 public Socket createSocket(Socket socket, String s, int i, boolean flag) throws IOException { 95 return factory.createSocket( socket, s, i, flag); 96 } 97 98 public Socket createSocket( InetAddress inaddr, int i, InetAddress inaddr1, int j) throws IOException { 99 return factory.createSocket( inaddr, i, inaddr1, j); 100 } 101 102 public Socket createSocket( InetAddress inaddr, int i) throws IOException { 103 return factory.createSocket( inaddr, i); 104 } 105 106 public Socket createSocket( String s, int i, InetAddress inaddr, int j) throws IOException { 107 return factory.createSocket( s, i, inaddr, j); 108 } 109 110 public Socket createSocket( String s, int i) throws IOException { 111 return factory.createSocket( s, i); 112 } 113 114 public String [] getDefaultCipherSuites() { 115 return factory.getSupportedCipherSuites(); 116 } 117 118 public String [] getSupportedCipherSuites() { 119 return factory.getSupportedCipherSuites(); 120 } 121 } 122 123 | Popular Tags |