Package fr.gpotter2.sslkeystorefactories
Class SSLSocketKeystoreFactory
- java.lang.Object
-
- fr.gpotter2.sslkeystorefactories.SSLSocketKeystoreFactory
-
public class SSLSocketKeystoreFactory extends Object
Util class to create SSLSocket using a KeyStore certificate to connect a server- Author:
- gpotter2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSSLSocketKeystoreFactory.SecureTypeA SSL algorithms types chooser enum
-
Constructor Summary
Constructors Constructor Description SSLSocketKeystoreFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SSLSocketgetSocketWithCert(String ip, int port, InputStream pathToCert, String passwordFromCert, SSLSocketKeystoreFactory.SecureType type)Instantiate sslsocketstatic SSLSocketgetSocketWithCert(String ip, int port, String pathToCert, String passwordFromCert, SSLSocketKeystoreFactory.SecureType type)Instantiate sslsocketstatic SSLSocketgetSocketWithCert(InetAddress ip, int port, InputStream pathToCert, String passwordFromCert, SSLSocketKeystoreFactory.SecureType type)Instantiate sslsocketstatic SSLSocketgetSocketWithCert(InetAddress ip, int port, InputStream pathToCert, String passwordFromCert, SSLSocketKeystoreFactory.SecureType type, Proxy proxy)Instantiate sslsocket (beta proxy)static SSLSocketgetSocketWithCert(InetAddress ip, int port, String pathToCert, String passwordFromCert, SSLSocketKeystoreFactory.SecureType type)Instantiate sslsocket
-
-
-
Method Detail
-
getSocketWithCert
public static SSLSocket getSocketWithCert(String ip, int port, String pathToCert, String passwordFromCert, SSLSocketKeystoreFactory.SecureType type) throws IOException, KeyManagementException, NoSuchAlgorithmException, CertificateException, KeyStoreException, SocketException
Instantiate sslsocket- Parameters:
ip- The IP to connect the socket toport- The port of the socketpathToCert- The path to the KeyStore cert (can be with getClass().getRessource()....)passwordFromCert- The password of the KeyStore certtype- The SSL algorithm to use- Returns:
- The SSLSocket or null if the connection was not possible
- Throws:
IOException- If the socket couldn't be createdKeyManagementException- If the KeyManager couldn't be loadedCertificateException- If the certificate is not correct (null or damaged) or the password is incorrectNoSuchAlgorithmException- If the certificate is from an unknown typeKeyStoreException- If your system is not compatible with JKS KeyStore certificatesSocketException
-
getSocketWithCert
public static SSLSocket getSocketWithCert(String ip, int port, InputStream pathToCert, String passwordFromCert, SSLSocketKeystoreFactory.SecureType type) throws IOException, KeyManagementException, NoSuchAlgorithmException, CertificateException, KeyStoreException, SocketException
Instantiate sslsocket- Parameters:
ip- The IP to connect the socket toport- The port of the socketpathToCert- The path to the KeyStore cert (can be with getClass().getRessourceAsStream()....)passwordFromCert- The password of the KeyStore certtype- The SSL algorithm to use- Returns:
- The SSLSocket or null if the connection was not possible
- Throws:
IOException- If the socket couldn't be createdKeyManagementException- If the KeyManager couldn't be loadedCertificateException- If the certificate is not correct (null or damaged) or the password is incorrectNoSuchAlgorithmException- If the certificate is from an unknown typeKeyStoreException- If your system is not compatible with JKS KeyStore certificatesSocketException
-
getSocketWithCert
public static SSLSocket getSocketWithCert(InetAddress ip, int port, String pathToCert, String passwordFromCert, SSLSocketKeystoreFactory.SecureType type) throws IOException, KeyManagementException, NoSuchAlgorithmException, CertificateException, KeyStoreException, SocketException
Instantiate sslsocket- Parameters:
ip- The IP to connect the socket toport- The port of the socketpathToCert- The path to the KeyStore cert (can be with getClass().getRessource()....)passwordFromCert- The password of the KeyStore certtype- The SSL algorithm to use- Returns:
- The SSLSocket or null if the connection was not possible
- Throws:
IOException- If the socket couldn't be createdKeyManagementException- If the KeyManager couldn't be loadedCertificateException- If the certificate is not correct (null or damaged) or the password is incorrectNoSuchAlgorithmException- If the certificate is from an unknown typeKeyStoreException- If your system is not compatible with JKS KeyStore certificatesSocketException
-
getSocketWithCert
public static SSLSocket getSocketWithCert(InetAddress ip, int port, InputStream pathToCert, String passwordFromCert, SSLSocketKeystoreFactory.SecureType type) throws IOException, KeyManagementException, NoSuchAlgorithmException, CertificateException, KeyStoreException, SocketException
Instantiate sslsocket- Parameters:
ip- The IP to connect the socket toport- The port of the socketpathToCert- The path to the KeyStore cert (can be with getClass().getRessourceAsStream()....)passwordFromCert- The password of the KeyStore certtype- The SSL algorithm to use- Returns:
- The SSLSocket or null if the connection was not possible
- Throws:
IOException- If the socket couldn't be createdKeyManagementException- If the KeyManager couldn't be loadedCertificateException- If the certificate is not correct (null or damaged) or the password is incorrectNoSuchAlgorithmException- If the certificate is from an unknown typeKeyStoreException- If your system is not compatible with JKS KeyStore certificatesSocketException
-
getSocketWithCert
public static SSLSocket getSocketWithCert(InetAddress ip, int port, InputStream pathToCert, String passwordFromCert, SSLSocketKeystoreFactory.SecureType type, Proxy proxy) throws IOException, KeyManagementException, NoSuchAlgorithmException, CertificateException, KeyStoreException, SocketException
Instantiate sslsocket (beta proxy)- Parameters:
ip- The IP to connect the socket toport- The port of the socketpathToCert- The path to the KeyStore cert (can be with getClass().getRessourceAsStream()....)passwordFromCert- The password of the KeyStore certtype- The SSL algorithm to use- Returns:
- The SSLSocket or null if the connection was not possible
- Throws:
IOException- If the socket couldn't be createdKeyManagementException- If the KeyManager couldn't be loadedCertificateException- If the certificate is not correct (null or damaged) or the password is incorrectNoSuchAlgorithmException- If the certificate is from an unknown typeKeyStoreException- If your system is not compatible with JKS KeyStore certificatesSocketException
-
-