-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
91 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package me.figo.internal; | ||
|
||
import java.io.IOException; | ||
import java.net.InetAddress; | ||
import java.net.Socket; | ||
import java.net.UnknownHostException; | ||
|
||
import javax.net.ssl.SSLSocket; | ||
import javax.net.ssl.SSLSocketFactory; | ||
|
||
public class FigoSocketFactory extends SSLSocketFactory { | ||
|
||
private static final String[] ENABLED_PROTOCOLS = { "TLSv1.2" }; | ||
|
||
private SSLSocketFactory isf; | ||
|
||
public FigoSocketFactory(SSLSocketFactory factory) { | ||
isf = factory; | ||
} | ||
|
||
@Override | ||
public String[] getDefaultCipherSuites() { | ||
return isf.getDefaultCipherSuites(); | ||
} | ||
|
||
@Override | ||
public String[] getSupportedCipherSuites() { | ||
return isf.getSupportedCipherSuites(); | ||
} | ||
|
||
@Override | ||
public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException { | ||
return enableProtocols(isf.createSocket(socket, host, port, autoClose)); | ||
} | ||
|
||
@Override | ||
public Socket createSocket(String host, int port) throws IOException, UnknownHostException { | ||
return enableProtocols(isf.createSocket(host, port)); | ||
} | ||
|
||
@Override | ||
public Socket createSocket(String remoteHost, int remotePort, InetAddress localHost, int localPort) | ||
throws IOException, UnknownHostException { | ||
return enableProtocols(isf.createSocket(remoteHost, remotePort, localHost, localPort)); | ||
} | ||
|
||
@Override | ||
public Socket createSocket(InetAddress host, int port) throws IOException { | ||
return enableProtocols(isf.createSocket(host, port)); | ||
} | ||
|
||
@Override | ||
public Socket createSocket(InetAddress remoteHost, int remotePort, InetAddress localHost, int localPort) | ||
throws IOException { | ||
return enableProtocols(isf.createSocket(remoteHost, remotePort, localHost, localPort)); | ||
} | ||
|
||
private Socket enableProtocols(Socket socket) { | ||
if (socket != null && socket instanceof SSLSocket) { | ||
((SSLSocket) socket).setEnabledProtocols(ENABLED_PROTOCOLS); | ||
} | ||
return socket; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters