CloudPlugs REST Library  1.0.0
for Android
SSL Class Reference

Tool class for easy manipulation of CA certificates over the SSL network. The developer should avoid a direct usage of this class when connecting to an official CloudPlugs server. More...

Static Public Member Functions

static void trustEveryone ()
 
static void trustCloudPlugs () throws KeyManagementException, KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException
 
static void trustCA (Certificate ca) throws KeyManagementException, KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException
 
static Certificate getCA (String ca, String type) throws CertificateException, UnsupportedEncodingException
 
static Certificate getCA (String ca) throws CertificateException, UnsupportedEncodingException
 
static Certificate getCA (byte[] ca, String type) throws CertificateException
 
static Certificate getCA (byte[] ca) throws CertificateException
 
static Certificate getCA (InputStream ca, String type) throws CertificateException
 
static Certificate getCA (InputStream ca) throws CertificateException
 
static TrustManagerFactory getTrustManagerFactoryOf (Certificate ca, String entry) throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException
 
static TrustManagerFactory getTrustManagerFactoryOf (Certificate ca) throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException
 
static SSLSocketFactory getSocketFactoryOf (Certificate ca) throws KeyManagementException, KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException
 

Detailed Description

Tool class for easy manipulation of CA certificates over the SSL network. The developer should avoid a direct usage of this class when connecting to an official CloudPlugs server.

Member Function Documentation

◆ getCA() [1/6]

static Certificate getCA ( String  ca,
String  type 
) throws CertificateException, UnsupportedEncodingException
static

Create a new instance of java.security.cert.Certificate by giving its type and its certificate encoded as a String.

Parameters
cathe certificate to trust
typethe type of certificate to generate
Returns
the instance of a java.security.cert.Certificate
Exceptions
CertificateException
UnsupportedEncodingException

◆ getCA() [2/6]

static Certificate getCA ( String  ca) throws CertificateException, UnsupportedEncodingException
static

Like getCA(String, String), but using the default type "X.509".

Parameters
cathe certificate to trust
Returns
the instance of a java.security.cert.Certificate
Exceptions
CertificateException
UnsupportedEncodingException

◆ getCA() [3/6]

static Certificate getCA ( byte []  ca,
String  type 
) throws CertificateException
static

Create a new instance of java.security.cert.Certificate by giving its type and its certificate encoded as a byte array.

Parameters
cathe certificate to trust
typethe type of certificate to generate
Returns
the instance of generated java.security.cert.Certificate
Exceptions
CertificateException

◆ getCA() [4/6]

static Certificate getCA ( byte []  ca) throws CertificateException
static

Like getCA(byte[], String), but using the default type "X.509".

Parameters
cathe certificate to trust
Returns
the instance of generated java.security.cert.Certificate
Exceptions
CertificateException

◆ getCA() [5/6]

static Certificate getCA ( InputStream  ca,
String  type 
) throws CertificateException
static

Create a new instance of java.security.cert.Certificate by giving its type and its certificate encoded readable by the specified java.io.InputStream.

Parameters
cathe java.io.InputStream where reading the certificate to trust
typethe type of certificate to generate
Returns
the instance of generated java.security.cert.Certificate
Exceptions
CertificateException

◆ getCA() [6/6]

static Certificate getCA ( InputStream  ca) throws CertificateException
static

Like getCA(InputStream, String), but using the default type "X.509".

Parameters
cathe java.ioInputStream where reading the certificate to trust
Returns
the instance of generated java.security.cert.Certificate
Exceptions
CertificateException

◆ getSocketFactoryOf()

static SSLSocketFactory getSocketFactoryOf ( Certificate  ca) throws KeyManagementException, KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException
static

Create a new instance of javax.net.ssl.SSLSocketFactory will allow safe connections with servers are using the specified certificate authority.

Parameters
cathe certificate to trust
Returns
the SSL socket socket factory allows safe connections using ca
Exceptions
KeyManagementException
KeyStoreException
CertificateException
NoSuchAlgorithmException
IOException

◆ getTrustManagerFactoryOf() [1/2]

static TrustManagerFactory getTrustManagerFactoryOf ( Certificate  ca,
String  entry 
) throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException
static

Create a new instance of javax.net.ssl.TrustManagerFactory for the specified certificate and entry.

Parameters
cathe certificate to trust
entrythe certificate entry
Returns
the trust manager factory related to the specified certificate
Exceptions
KeyStoreException
CertificateException
NoSuchAlgorithmException
IOException

◆ getTrustManagerFactoryOf() [2/2]

static TrustManagerFactory getTrustManagerFactoryOf ( Certificate  ca) throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException
static

Create a new instance of javax.net.ssl.TrustManagerFactory for the specified certificate authority.

Parameters
cathe certificate to trust
Returns
the trust manager factory related to the specified certificate authority
Exceptions
KeyStoreException
CertificateException
NoSuchAlgorithmException
IOException

◆ trustCA()

static void trustCA ( Certificate  ca) throws KeyManagementException, KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException
static

Allow safe SSL connections to any server is using the specified certificate.

Parameters
cathe certificate to trust
Exceptions
KeyManagementException
KeyStoreException
CertificateException
NoSuchAlgorithmException
IOException

◆ trustCloudPlugs()

static void trustCloudPlugs ( ) throws KeyManagementException, KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException
static

Allow safe SSL connections to the official CloudPlugs server. The developer does not need to invoke this method, it will be automatically invoked by other classes of the library.

Exceptions
KeyManagementException
KeyStoreException
CertificateException
NoSuchAlgorithmException
IOException

◆ trustEveryone()

static void trustEveryone ( )
static

Disable the peer and host verification when establishing any SSL connection, including HTTPS ones. This will allow any SSL connection also with untrusted peers in a easy way. The invocation of this method is discouraged due to security reasons, because it will permit Man-In-The-Middle attacks.