-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathTLSConnection.java
More file actions
37 lines (30 loc) · 969 Bytes
/
TLSConnection.java
File metadata and controls
37 lines (30 loc) · 969 Bytes
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
package HTTPClient;
import java.net.Socket;
import java.io.IOException;
import java.net.InetAddress;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
public class TLSConnection implements ISSLConnection
{
private static SSLSocketFactory socketFactory = (SSLSocketFactory)SSLSocketFactory.getDefault();
public TLSConnection() {}
public Socket processSSLSocket(Socket fromSocket, String host, int port) throws IOException
{
((SSLSocket)fromSocket).startHandshake();
return fromSocket;
}
public Socket getSSLSocket(InetAddress addr, int port) throws IOException
{
SSLSocket socket = (SSLSocket)socketFactory.createSocket(addr, port);
return socket;
}
public Socket getSSLSocket(InetAddress addr, int port, InetAddress localAddr, int localPort) throws IOException
{
SSLSocket socket = (SSLSocket)socketFactory.createSocket(addr, port, localAddr, localPort);
return socket;
}
public Object clone()
{
return this;
}
}