Class PEMCredential

    • Constructor Detail

      • PEMCredential

        public PEMCredential​(java.lang.String keystorePath,
                             char[] keyPasswd)
                      throws java.io.IOException,
                             java.security.KeyStoreException,
                             java.security.cert.CertificateException
        Constructs the object from InputStream which can be used to read a private key and certificate in PEM keystore format, i.e. the file must contain both certificates and a private key. See CertificateUtils.loadPEMKeystore(InputStream, char[], char[]) for details.
        Parameters:
        keystorePath - file path with the PEM keystore
        keyPasswd - Password used to decrypt the key. May be null if the key is not encrypted.
        Throws:
        java.io.IOException - if the stream can not be read
        java.security.KeyStoreException - if private key can not be parsed or decrypted
        java.security.cert.CertificateException - if certificate can not be parsed
      • PEMCredential

        public PEMCredential​(java.lang.String keystorePath,
                             PasswordSupplier pf)
                      throws java.io.IOException,
                             java.security.KeyStoreException,
                             java.security.cert.CertificateException
        As PEMCredential(String, char[]) but this version allows for providing decryption key only when needed.
        Parameters:
        keystorePath - file path with the PEM keystore
        pf - object to retrieve password on demand.
        Throws:
        java.io.IOException - if the stream can not be read
        java.security.KeyStoreException - if private key can not be parsed or decrypted
        java.security.cert.CertificateException - if certificate can not be parsed
        Since:
        1.1.0
      • PEMCredential

        public PEMCredential​(java.io.InputStream keystoreStream,
                             char[] keyPasswd)
                      throws java.io.IOException,
                             java.security.KeyStoreException,
                             java.security.cert.CertificateException
        Constructs the object from InputStream which can be used to read a private key and certificate in PEM keystore format, i.e. the file must contain both certificates and a private key. See CertificateUtils.loadPEMKeystore(InputStream, char[], char[]) for details.

        The stream is closed after constructing the object.

        Parameters:
        keystoreStream - InputStream which can be used to read the PEM keystore
        keyPasswd - Password used to decrypt the key. May be null if the key is not encrypted.
        Throws:
        java.io.IOException - if the stream can not be read
        java.security.KeyStoreException - if private key can not be parsed or decrypted
        java.security.cert.CertificateException - if certificate can not be parsed
      • PEMCredential

        public PEMCredential​(java.io.InputStream keystoreStream,
                             PasswordSupplier pf)
                      throws java.io.IOException,
                             java.security.KeyStoreException,
                             java.security.cert.CertificateException
        As PEMCredential(InputStream, char[]) but this version allows for providing decryption key only when needed.
        Parameters:
        keystoreStream - InputStream which can be used to read the PEM keystore
        pf - object to retrieve password on demand.
        Throws:
        java.io.IOException - if the stream can not be read
        java.security.KeyStoreException - if private key can not be parsed or decrypted
        java.security.cert.CertificateException - if certificate can not be parsed
        Since:
        1.1.0
      • PEMCredential

        public PEMCredential​(java.io.InputStream privateKeyStream,
                             java.io.InputStream certificateStream,
                             char[] keyPasswd)
                      throws java.io.IOException,
                             java.security.KeyStoreException,
                             java.security.cert.CertificateException
        Constructs the object from two InputStreams which can be used to read a private key and certificate in PEM format.

        The streams are closed after constructing the object.

        Parameters:
        privateKeyStream - InputStream which can be used to read the private key in PEM format
        certificateStream - certificate in PEM format InputStream
        keyPasswd - Password used to decrypt the key. May be null if the key is not encrypted.
        Throws:
        java.io.IOException - if any of the streams can not be read
        java.security.KeyStoreException - if private key can not be parsed or decrypted
        java.security.cert.CertificateException - if certificate can not be parsed
      • PEMCredential

        public PEMCredential​(java.io.InputStream privateKeyStream,
                             java.io.InputStream certificateStream,
                             PasswordSupplier pf)
                      throws java.io.IOException,
                             java.security.KeyStoreException,
                             java.security.cert.CertificateException
        As PEMCredential(InputStream, InputStream, char[]) but password is retrieved on demand.
        Parameters:
        privateKeyStream - InputStream which can be used to read the private key in PEM format
        certificateStream - certificate in PEM format InputStream
        pf - object to retrieve password on demand.
        Throws:
        java.io.IOException - if any of the streams can not be read
        java.security.KeyStoreException - if private key can not be parsed or decrypted
        java.security.cert.CertificateException - if certificate can not be parsed
        Since:
        1.1.0
      • PEMCredential

        public PEMCredential​(java.io.Reader privateKeyReader,
                             java.io.Reader certificateReader,
                             char[] keyPasswd)
                      throws java.io.IOException,
                             java.security.KeyStoreException,
                             java.security.cert.CertificateException
        Constructs the object from two Readers which can be used to read a private key and certificate in PEM format.

        The streams are closed after constructing the object.

        Parameters:
        privateKeyReader - Reader which can be used to read the PEM private key
        certificateReader - certificate file Reader
        keyPasswd - Password used to decrypt the key. May be null if the key is not encrypted.
        Throws:
        java.io.IOException - if any of files can not be read
        java.security.KeyStoreException - if private key can not be parsed or decrypted
        java.security.cert.CertificateException - if certificate can not be parsed
      • PEMCredential

        public PEMCredential​(java.io.Reader privateKeyReader,
                             java.io.Reader certificateReader,
                             PasswordSupplier pf)
                      throws java.io.IOException,
                             java.security.KeyStoreException,
                             java.security.cert.CertificateException
        As PEMCredential(Reader, Reader, char[]) but password is retrieved on demand.
        Parameters:
        privateKeyReader - Reader which can be used to read the PEM private key
        certificateReader - certificate file Reader
        pf - object to retrieve password on demand.
        Throws:
        java.io.IOException - if any of files can not be read
        java.security.KeyStoreException - if private key can not be parsed or decrypted
        java.security.cert.CertificateException - if certificate can not be parsed
        Since:
        1.1.0
      • PEMCredential

        public PEMCredential​(java.lang.String keyPath,
                             java.lang.String certificatePath,
                             char[] keyPasswd)
                      throws java.io.IOException,
                             java.security.KeyStoreException,
                             java.security.cert.CertificateException
        Constructs the object from two files containing private key and certificate in PEM format.

        The streams are closed after constructing the object.

        Parameters:
        keyPath - private key file path
        certificatePath - certificate file path
        keyPasswd - Password used to decrypt the key. May be null if the key is not encrypted.
        Throws:
        java.io.IOException - if any of files can not be read
        java.security.KeyStoreException - if private key can not be parsed or decrypted
        java.security.cert.CertificateException - if certificate can not be parsed