Platform SDK Java 8.5 API Reference

com.genesyslab.platform.commons.connection.tls
Class CertificateLoader

java.lang.Object
  extended by com.genesyslab.platform.commons.connection.tls.CertificateLoader

public class CertificateLoader
extends java.lang.Object

Provides static methods to load keys, certificates and CRLs from file formats supported by Genesys Framework.


Constructor Summary
CertificateLoader()
           
 
Method Summary
static java.security.PrivateKey createKeyFromPKCS8Bytes(byte[] encodedKey)
          Converts encoded key data to PrivetKey instance.
static java.security.PrivateKey createKeyFromX509Bytes(byte[] encodedKey)
          Converts encoded key data to PrivetKey instance.
static java.security.cert.Certificate loadCertificateFromX509PEM(java.io.InputStream inputStream)
          Loads single certificate in X.509 PEM format from InputStream.
static java.security.cert.Certificate loadCertificateFromX509PEM(java.lang.String path)
          Loads single certificate in X.509 PEM format from InputStream.
static java.security.cert.Certificate[] loadCertificatesFromX509PEM(java.io.InputStream inputStream)
          Loads chain of certificates in X.509 PEM format from InputStream.
static java.security.cert.Certificate[] loadCertificatesFromX509PEM(java.lang.String path)
          Loads chain of certificates in X.509 PEM format from file.
static java.util.Collection<? extends java.security.cert.CRL> loadCRLFromPEM(java.io.InputStream inputStream)
          Loads CRLs from InputStream
static java.util.Collection<? extends java.security.cert.CRL> loadCRLFromPEM(java.lang.String path)
          Loads CRLs from file
static java.security.PrivateKey loadKeyFromPEM(java.io.InputStream inputStream)
          Loads single private key in PKCS#8 OR X.509 PEM format from InputStream.
static java.security.PrivateKey loadKeyFromPEM(java.lang.String path)
          Loads single private key in PKCS#8 or X.509 PEM format from file.
static java.security.PrivateKey loadKeyFromPKCS8DER(java.io.InputStream inputStream)
          Loads single private key in PKCS#8 DER format from InputStream.
static java.security.PrivateKey loadKeyFromPKCS8DER(java.lang.String path)
          Loads single private key in PKCS#8 DER format from file.
static java.security.PrivateKey loadKeyFromPKCS8PEM(java.io.InputStream inputStream)
          Loads single private key in PKCS#8 PEM format from InputStream.
static java.security.PrivateKey loadKeyFromPKCS8PEM(java.lang.String path)
          Loads single private key in PKCS#8 PEM format from file.
static java.security.PrivateKey loadKeyFromX509DER(java.io.InputStream inputStream)
          Loads single private key in X.509 DER format from InputStream.
static java.security.PrivateKey loadKeyFromX509DER(java.lang.String path)
          Loads single private key in X.509 DER format from file.
static java.security.PrivateKey loadKeyFromX509PEM(java.io.InputStream inputStream)
          Loads single private key in X.509 PEM format from InputStream.
static java.security.PrivateKey loadKeyFromX509PEM(java.lang.String path)
          Loads single private key in X.509 PEM format from file.
static byte[] readFully(java.io.InputStream inputStream)
          Utilty method that loads whole stream contents to byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CertificateLoader

public CertificateLoader()
Method Detail

loadCertificatesFromX509PEM

public static java.security.cert.Certificate[] loadCertificatesFromX509PEM(java.io.InputStream inputStream)
                                                                    throws java.security.GeneralSecurityException,
                                                                           java.io.IOException
Loads chain of certificates in X.509 PEM format from InputStream.

Parameters:
inputStream - Stream to load from
Returns:
Chain of certificates loaded from stream
Throws:
java.security.GeneralSecurityException - If there are problems with stream format and/or data
java.io.IOException - If there are problems reading stream

loadCertificatesFromX509PEM

public static java.security.cert.Certificate[] loadCertificatesFromX509PEM(java.lang.String path)
                                                                    throws java.security.GeneralSecurityException,
                                                                           java.io.IOException
Loads chain of certificates in X.509 PEM format from file.

Parameters:
path - Path to file to load from
Returns:
Chain of certificates loaded from stream
Throws:
java.security.GeneralSecurityException - If there are problems with stream format and/or data
java.io.IOException - If there are problems reading stream

loadCertificateFromX509PEM

public static java.security.cert.Certificate loadCertificateFromX509PEM(java.io.InputStream inputStream)
                                                                 throws java.security.GeneralSecurityException,
                                                                        java.io.IOException
Loads single certificate in X.509 PEM format from InputStream. If there are several certificates, only the first one will be loaded.

Parameters:
inputStream - Stream to load from
Returns:
Certificate loaded from stream
Throws:
java.security.GeneralSecurityException - If there are problems with stream format and/or data
java.io.IOException - If there are problems reading stream

loadCertificateFromX509PEM

public static java.security.cert.Certificate loadCertificateFromX509PEM(java.lang.String path)
                                                                 throws java.security.GeneralSecurityException,
                                                                        java.io.IOException
Loads single certificate in X.509 PEM format from InputStream. If there are several certificates, only the first one will be loaded.

Parameters:
path - Path to file to load from
Returns:
Certificate loaded from stream
Throws:
java.security.GeneralSecurityException - If there are problems with stream format and/or data
java.io.IOException - If there are problems reading stream

loadKeyFromX509PEM

public static java.security.PrivateKey loadKeyFromX509PEM(java.io.InputStream inputStream)
                                                   throws java.security.GeneralSecurityException,
                                                          java.io.IOException
Loads single private key in X.509 PEM format from InputStream.

Parameters:
inputStream - Path to file to load from
Returns:
Private key loaded from stream
Throws:
java.security.GeneralSecurityException - If there are problems with stream format and/or data
java.io.IOException - If there are problems reading stream

loadKeyFromPKCS8PEM

public static java.security.PrivateKey loadKeyFromPKCS8PEM(java.io.InputStream inputStream)
                                                    throws java.security.GeneralSecurityException,
                                                           java.io.IOException
Loads single private key in PKCS#8 PEM format from InputStream.

Parameters:
inputStream - Path to file to load from
Returns:
Private key loaded from stream
Throws:
java.security.GeneralSecurityException - If there are problems with stream format and/or data
java.io.IOException - If there are problems reading stream

loadKeyFromPEM

public static java.security.PrivateKey loadKeyFromPEM(java.io.InputStream inputStream)
                                               throws java.security.GeneralSecurityException,
                                                      java.io.IOException
Loads single private key in PKCS#8 OR X.509 PEM format from InputStream.

Parameters:
inputStream - Path to file to load from
Returns:
Private key loaded from stream.
Throws:
java.security.GeneralSecurityException - If there are problems with stream format and/or data
java.io.IOException - If there are problems reading stream

loadKeyFromPEM

public static java.security.PrivateKey loadKeyFromPEM(java.lang.String path)
                                               throws java.security.GeneralSecurityException,
                                                      java.io.IOException
Loads single private key in PKCS#8 or X.509 PEM format from file.

Parameters:
path - Path to file to load from
Returns:
Private key loaded from stream
Throws:
java.security.GeneralSecurityException - If there are problems with stream format and/or data
java.io.IOException - If there are problems reading stream

loadKeyFromX509PEM

public static java.security.PrivateKey loadKeyFromX509PEM(java.lang.String path)
                                                   throws java.security.GeneralSecurityException,
                                                          java.io.IOException
Loads single private key in X.509 PEM format from file.

Parameters:
path - Path to file to load from
Returns:
Private key loaded from stream
Throws:
java.security.GeneralSecurityException - If there are problems with stream format and/or data
java.io.IOException - If there are problems reading stream

loadKeyFromPKCS8PEM

public static java.security.PrivateKey loadKeyFromPKCS8PEM(java.lang.String path)
                                                    throws java.security.GeneralSecurityException,
                                                           java.io.IOException
Loads single private key in PKCS#8 PEM format from file.

Parameters:
path - Path to file to load from
Returns:
Private key loaded from stream
Throws:
java.security.GeneralSecurityException - If there are problems with stream format and/or data
java.io.IOException - If there are problems reading stream

loadKeyFromX509DER

public static java.security.PrivateKey loadKeyFromX509DER(java.io.InputStream inputStream)
                                                   throws java.security.GeneralSecurityException,
                                                          java.io.IOException
Loads single private key in X.509 DER format from InputStream.

Parameters:
inputStream - Stream to load from
Returns:
Private key loaded from stream
Throws:
java.security.GeneralSecurityException - If there are problems with stream format and/or data
java.io.IOException - If there are problems reading stream

loadKeyFromX509DER

public static java.security.PrivateKey loadKeyFromX509DER(java.lang.String path)
                                                   throws java.security.GeneralSecurityException,
                                                          java.io.IOException
Loads single private key in X.509 DER format from file.

Parameters:
path - Path to file to load from
Returns:
Private key loaded from stream
Throws:
java.security.GeneralSecurityException - If there are problems with stream format and/or data
java.io.IOException - If there are problems reading stream

loadKeyFromPKCS8DER

public static java.security.PrivateKey loadKeyFromPKCS8DER(java.io.InputStream inputStream)
                                                    throws java.security.GeneralSecurityException,
                                                           java.io.IOException
Loads single private key in PKCS#8 DER format from InputStream.

Parameters:
inputStream - Stream to load from
Returns:
Private key loaded from stream
Throws:
java.security.GeneralSecurityException - If there are problems with stream format and/or data
java.io.IOException - If there are problems reading stream

loadKeyFromPKCS8DER

public static java.security.PrivateKey loadKeyFromPKCS8DER(java.lang.String path)
                                                    throws java.security.GeneralSecurityException,
                                                           java.io.IOException
Loads single private key in PKCS#8 DER format from file.

Parameters:
path - Path to file to load from
Returns:
Private key loaded from stream
Throws:
java.security.GeneralSecurityException - If there are problems with stream format and/or data
java.io.IOException - If there are problems reading stream

createKeyFromPKCS8Bytes

public static java.security.PrivateKey createKeyFromPKCS8Bytes(byte[] encodedKey)
                                                        throws java.security.GeneralSecurityException
Converts encoded key data to PrivetKey instance.

Parameters:
encodedKey - Raw private key data
Returns:
Private key instance
Throws:
java.security.GeneralSecurityException - If there are problems with data format

createKeyFromX509Bytes

public static java.security.PrivateKey createKeyFromX509Bytes(byte[] encodedKey)
                                                       throws java.security.GeneralSecurityException
Converts encoded key data to PrivetKey instance.

Parameters:
encodedKey - Raw private key data
Returns:
Private key instance
Throws:
java.security.GeneralSecurityException - If there are problems with data format

loadCRLFromPEM

public static java.util.Collection<? extends java.security.cert.CRL> loadCRLFromPEM(java.io.InputStream inputStream)
                                                                             throws java.security.GeneralSecurityException,
                                                                                    java.io.IOException
Loads CRLs from InputStream

Parameters:
inputStream - Stream to load from
Returns:
Loaded CRLs
Throws:
java.security.GeneralSecurityException - If there are problems with format and/or data
java.io.IOException - If there are problems reading stream

loadCRLFromPEM

public static java.util.Collection<? extends java.security.cert.CRL> loadCRLFromPEM(java.lang.String path)
                                                                             throws java.security.GeneralSecurityException,
                                                                                    java.io.IOException
Loads CRLs from file

Parameters:
path - Path to file to load from
Returns:
Loaded CRLs
Throws:
java.security.GeneralSecurityException - If there are problems with format and/or data
java.io.IOException - If there are problems reading stream

readFully

public static byte[] readFully(java.io.InputStream inputStream)
                        throws java.io.IOException
Utilty method that loads whole stream contents to byte array.

Parameters:
inputStream - Stream to load from
Returns:
Array of bytes loaded from stream
Throws:
java.io.IOException - If there are problems reading stream

Platform SDK Java 8.5 API Reference

Send comments on this topicTechpubs.webadmin@genesys.com.
Document version: 8.5.302.00
Copyright © 2006–2017 Genesys Telecommunications Laboratories, Inc. All rights reserved.