01: package org.claros.commons.mail.protocols;
02:
03: import com.sun.net.ssl.*;
04: import java.io.IOException;
05: import java.net.InetAddress;
06: import java.net.Socket;
07: import javax.net.SocketFactory;
08: import javax.net.ssl.SSLSocketFactory;
09:
10: public class DummySSLSocketFactory extends SSLSocketFactory {
11: private SSLSocketFactory factory;
12:
13: @SuppressWarnings("deprecation")
14: public DummySSLSocketFactory() {
15: System.out.println("DummySocketFactory instantiated");
16: try {
17: SSLContext sslcontext = SSLContext.getInstance("TLS");
18: sslcontext.init(
19: null, // No KeyManager required
20: new TrustManager[] { new DummyTrustManager() },
21: new java.security.SecureRandom());
22: factory = (SSLSocketFactory) sslcontext.getSocketFactory();
23: } catch (Exception ex) {
24: ex.printStackTrace();
25: }
26: }
27:
28: public static SocketFactory getDefault() {
29: return new DummySSLSocketFactory();
30: }
31:
32: public Socket createSocket(Socket socket, String s, int i,
33: boolean flag) throws IOException {
34: return factory.createSocket(socket, s, i, flag);
35: }
36:
37: public Socket createSocket(InetAddress inaddr, int i,
38: InetAddress inaddr1, int j) throws IOException {
39: return factory.createSocket(inaddr, i, inaddr1, j);
40: }
41:
42: public Socket createSocket(InetAddress inaddr, int i)
43: throws IOException {
44: return factory.createSocket(inaddr, i);
45: }
46:
47: public Socket createSocket(String s, int i, InetAddress inaddr,
48: int j) throws IOException {
49: return factory.createSocket(s, i, inaddr, j);
50: }
51:
52: public Socket createSocket(String s, int i) throws IOException {
53: return factory.createSocket(s, i);
54: }
55:
56: public String[] getDefaultCipherSuites() {
57: return factory.getSupportedCipherSuites();
58: }
59:
60: public String[] getSupportedCipherSuites() {
61: return factory.getSupportedCipherSuites();
62: }
63:
64: public Socket createSocket() throws IOException {
65: return factory.createSocket();
66: }
67:
68: }
|