-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathJSSESSLConnection.java
More file actions
94 lines (78 loc) · 2.34 KB
/
JSSESSLConnection.java
File metadata and controls
94 lines (78 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package HTTPClient;
import com.genexus.common.interfaces.SpecificImplementation;
import java.net.*;
import java.io.IOException;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
/** Esta clase provee un Binding SSL para la libreria JSSE de Sun
*
*/
public class JSSESSLConnection implements ISSLConnection
{
private static SSLSocketFactory defaultSSLFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
private SSLSocketFactory sslFactory = defaultSSLFactory;
public JSSESSLConnection() throws Exception
{
}
public Socket processSSLSocket(Socket fromSocket, String host, int port) throws IOException
{
SSLSocket sock = (SSLSocket)sslFactory.createSocket(fromSocket, host, port, true);
if (SpecificImplementation.HttpClient != null)
SpecificImplementation.HttpClient.prepareSSLSocket( sock);
return sock;
}
public Socket getSSLSocket(InetAddress addr, int port) throws IOException
{
return new Socket(addr, port);
}
public Socket getSSLSocket(InetAddress addr, int port, InetAddress localAddr, int localPort) throws IOException
{
return new Socket(addr, port, localAddr, localPort);
}
public Object clone()
{
return this;
}
public String toString()
{
return "JSSE SSL Connection, using: " + sslFactory;
}
/**
* Set the SSL socket factory for this connection. If not set, uses the
* default factory.
*
* @param sslFactory the SSL socket factory
*/
public static void setDefaultSSLSocketFactory(SSLSocketFactory sslFactory)
{
defaultSSLFactory = sslFactory;
}
/**
* Set the current SSL socket factory for this connection.
*
* @return the current SSL socket factory
*/
public static SSLSocketFactory getDefaultSSLSocketFactory()
{
return defaultSSLFactory;
}
/**
* Set the SSL socket factory for this connection. If not set, uses the
* default factory.
*
* @param sslFactory the SSL socket factory
*/
public void setSSLSocketFactory(SSLSocketFactory sslFactory)
{
this.sslFactory = sslFactory;
}
/**
* Set the current SSL socket factory for this connection.
*
* @return the current SSL socket factory
*/
public SSLSocketFactory getSSLSocketFactory()
{
return sslFactory;
}
}