1 24 25 package org.objectweb.cjdbc.common.net; 26 27 import java.io.IOException ; 28 import java.io.Serializable ; 29 import java.net.InetAddress ; 30 import java.net.Socket ; 31 import java.net.UnknownHostException ; 32 33 import javax.net.ssl.SSLSocket; 34 import javax.net.ssl.SSLSocketFactory; 35 36 46 public class AuthenticatedSocketFactory extends SSLSocketFactory 47 implements 48 Serializable 49 { 50 51 private static final long serialVersionUID = 3408254276587727154L; 52 53 private SSLSocketFactory factory; 54 55 60 public AuthenticatedSocketFactory(SSLSocketFactory factory) 61 { 62 this.factory = factory; 63 } 64 65 68 public Socket createSocket(String host, int port) throws IOException , 69 UnknownHostException 70 { 71 SSLSocket socket = (SSLSocket) factory.createSocket(host, port); 72 socket.setNeedClientAuth(true); 73 return socket; 74 } 75 76 79 public Socket createSocket(InetAddress host, int port) throws IOException 80 { 81 SSLSocket socket = (SSLSocket) factory.createSocket(host, port); 82 socket.setNeedClientAuth(true); 83 return socket; 84 } 85 86 90 public Socket createSocket(String host, int port, InetAddress localAddress, 91 int localPort) throws IOException , UnknownHostException 92 { 93 SSLSocket socket = (SSLSocket) factory.createSocket(host, port, 94 localAddress, localPort); 95 socket.setNeedClientAuth(true); 96 return socket; 97 } 98 99 103 public Socket createSocket(InetAddress address, int port, 104 InetAddress localAddress, int localPort) throws IOException 105 { 106 SSLSocket socket = (SSLSocket) factory.createSocket(address, port, 107 localAddress, localPort); 108 socket.setNeedClientAuth(true); 109 return socket; 110 } 111 112 116 public Socket createSocket(Socket s, String host, int port, boolean autoClose) 117 throws IOException 118 { 119 SSLSocket socket = (SSLSocket) factory.createSocket(s, host, port, 120 autoClose); 121 socket.setNeedClientAuth(true); 122 return socket; 123 } 124 125 128 public String [] getDefaultCipherSuites() 129 { 130 return factory.getDefaultCipherSuites(); 131 } 132 133 136 public String [] getSupportedCipherSuites() 137 { 138 return factory.getDefaultCipherSuites(); 139 } 140 141 } 142 | Popular Tags |