1 package org.lucane.applications.jmail.base; 2 3 22 23 import java.io.*; 24 import java.net.*; 25 import java.security.*; 26 import javax.net.*; 27 import javax.net.ssl.*; 28 29 30 public class JMailSSLSocketFactory extends SSLSocketFactory 31 { 32 SSLSocketFactory socketfactory; 33 34 public JMailSSLSocketFactory() 35 { 36 try 37 { 38 SSLContext sslcontext = SSLContext.getInstance("TLS"); 39 40 sslcontext.init(null, new TrustManager[] 41 { 42 new JMailTrustManager() 43 }, new SecureRandom()); 44 45 socketfactory = (SSLSocketFactory)sslcontext.getSocketFactory(); 46 } 47 48 catch(Exception ex) 49 { 50 ex.printStackTrace(); 51 } 52 } 53 54 public static SocketFactory getDefault() 55 { 56 return((SocketFactory)new JMailSSLSocketFactory()); 57 } 58 59 public Socket createSocket(Socket s, String hostaddress, int hostport, boolean autoClose) throws IOException 60 { 61 return(socketfactory.createSocket(s, hostaddress, hostport, autoClose)); 62 } 63 64 public Socket createSocket(InetAddress hostaddress, int hostport) throws IOException 65 { 66 return(socketfactory.createSocket(hostaddress, hostport)); 67 } 68 69 public Socket createSocket(InetAddress hostaddress, int hostport, InetAddress clientaddress, int clientport) throws IOException 70 { 71 return(socketfactory.createSocket(hostaddress, hostport, clientaddress, clientport)); 72 } 73 74 public Socket createSocket(String hostaddress, int hostport) throws IOException 75 { 76 return(socketfactory.createSocket(hostaddress, hostport)); 77 } 78 79 public Socket createSocket(String hostaddress, int hostport, InetAddress clientaddress, int clientport) throws IOException 80 { 81 return(socketfactory.createSocket(hostaddress, hostport, clientaddress, clientport)); 82 } 83 84 public String [] getDefaultCipherSuites() 85 { 86 return(socketfactory.getDefaultCipherSuites()); 87 } 88 89 public String [] getSupportedCipherSuites() 90 { 91 return(socketfactory.getSupportedCipherSuites()); 92 } 93 } 94 | Popular Tags |