Package eu.emi.security.authn.x509.impl
Class PEMCredential
java.lang.Object
eu.emi.security.authn.x509.helpers.AbstractDelegatingX509Credential
eu.emi.security.authn.x509.impl.PEMCredential
- All Implemented Interfaces:
X509Credential
Wraps certificate and private key stored in PEM format.
- Author:
- K. Benedyczak
-
Field Summary
Fields inherited from class eu.emi.security.authn.x509.helpers.AbstractDelegatingX509Credential
delegate -
Constructor Summary
ConstructorsConstructorDescriptionPEMCredential(InputStream keystoreStream, char[] keyPasswd) Constructs the object fromInputStreamwhich can be used to read a private key and certificate in PEM keystore format, i.e.PEMCredential(InputStream keystoreStream, PasswordSupplier pf) AsPEMCredential(InputStream, char[])but this version allows for providing decryption key only when needed.PEMCredential(InputStream privateKeyStream, InputStream certificateStream, char[] keyPasswd) Constructs the object from twoInputStreams which can be used to read a private key and certificate in PEM format.PEMCredential(InputStream privateKeyStream, InputStream certificateStream, PasswordSupplier pf) AsPEMCredential(InputStream, InputStream, char[])but password is retrieved on demand.PEMCredential(Reader privateKeyReader, Reader certificateReader, char[] keyPasswd) Constructs the object from twoReaders which can be used to read a private key and certificate in PEM format.PEMCredential(Reader privateKeyReader, Reader certificateReader, PasswordSupplier pf) AsPEMCredential(Reader, Reader, char[])but password is retrieved on demand.PEMCredential(String keystorePath, char[] keyPasswd) Constructs the object fromInputStreamwhich can be used to read a private key and certificate in PEM keystore format, i.e.PEMCredential(String keystorePath, PasswordSupplier pf) AsPEMCredential(String, char[])but this version allows for providing decryption key only when needed.PEMCredential(String keyPath, String certificatePath, char[] keyPasswd) Constructs the object from two files containing private key and certificate in PEM format. -
Method Summary
Methods inherited from class eu.emi.security.authn.x509.helpers.AbstractDelegatingX509Credential
getCertificate, getCertificateChain, getKey, getKeyAlias, getKeyManager, getKeyPassword, getKeyStore, getSubjectName
-
Constructor Details
-
PEMCredential
public PEMCredential(String keystorePath, char[] keyPasswd) throws IOException, KeyStoreException, CertificateException Constructs the object fromInputStreamwhich 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. SeeCertificateUtils.loadPEMKeystore(InputStream, char[], char[])for details.- Parameters:
keystorePath- file path with the PEM keystorekeyPasswd- Password used to decrypt the key. May be null if the key is not encrypted.- Throws:
IOException- if the stream can not be readKeyStoreException- if private key can not be parsed or decryptedCertificateException- if certificate can not be parsed
-
PEMCredential
public PEMCredential(String keystorePath, PasswordSupplier pf) throws IOException, KeyStoreException, CertificateException AsPEMCredential(String, char[])but this version allows for providing decryption key only when needed.- Parameters:
keystorePath- file path with the PEM keystorepf- object to retrieve password on demand.- Throws:
IOException- if the stream can not be readKeyStoreException- if private key can not be parsed or decryptedCertificateException- if certificate can not be parsed- Since:
- 1.1.0
-
PEMCredential
public PEMCredential(InputStream keystoreStream, char[] keyPasswd) throws IOException, KeyStoreException, CertificateException Constructs the object fromInputStreamwhich 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. SeeCertificateUtils.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 keystorekeyPasswd- Password used to decrypt the key. May be null if the key is not encrypted.- Throws:
IOException- if the stream can not be readKeyStoreException- if private key can not be parsed or decryptedCertificateException- if certificate can not be parsed
-
PEMCredential
public PEMCredential(InputStream keystoreStream, PasswordSupplier pf) throws IOException, KeyStoreException, CertificateException AsPEMCredential(InputStream, char[])but this version allows for providing decryption key only when needed.- Parameters:
keystoreStream- InputStream which can be used to read the PEM keystorepf- object to retrieve password on demand.- Throws:
IOException- if the stream can not be readKeyStoreException- if private key can not be parsed or decryptedCertificateException- if certificate can not be parsed- Since:
- 1.1.0
-
PEMCredential
public PEMCredential(InputStream privateKeyStream, InputStream certificateStream, char[] keyPasswd) throws IOException, KeyStoreException, CertificateException Constructs the object from twoInputStreams 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 formatcertificateStream- certificate in PEM format InputStreamkeyPasswd- Password used to decrypt the key. May be null if the key is not encrypted.- Throws:
IOException- if any of the streams can not be readKeyStoreException- if private key can not be parsed or decryptedCertificateException- if certificate can not be parsed
-
PEMCredential
public PEMCredential(InputStream privateKeyStream, InputStream certificateStream, PasswordSupplier pf) throws IOException, KeyStoreException, CertificateException AsPEMCredential(InputStream, InputStream, char[])but password is retrieved on demand.- Parameters:
privateKeyStream- InputStream which can be used to read the private key in PEM formatcertificateStream- certificate in PEM format InputStreampf- object to retrieve password on demand.- Throws:
IOException- if any of the streams can not be readKeyStoreException- if private key can not be parsed or decryptedCertificateException- if certificate can not be parsed- Since:
- 1.1.0
-
PEMCredential
public PEMCredential(Reader privateKeyReader, Reader certificateReader, char[] keyPasswd) throws IOException, KeyStoreException, CertificateException Constructs the object from twoReaders 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 keycertificateReader- certificate file ReaderkeyPasswd- Password used to decrypt the key. May be null if the key is not encrypted.- Throws:
IOException- if any of files can not be readKeyStoreException- if private key can not be parsed or decryptedCertificateException- if certificate can not be parsed
-
PEMCredential
public PEMCredential(Reader privateKeyReader, Reader certificateReader, PasswordSupplier pf) throws IOException, KeyStoreException, CertificateException AsPEMCredential(Reader, Reader, char[])but password is retrieved on demand.- Parameters:
privateKeyReader- Reader which can be used to read the PEM private keycertificateReader- certificate file Readerpf- object to retrieve password on demand.- Throws:
IOException- if any of files can not be readKeyStoreException- if private key can not be parsed or decryptedCertificateException- if certificate can not be parsed- Since:
- 1.1.0
-
PEMCredential
public PEMCredential(String keyPath, String certificatePath, char[] keyPasswd) throws IOException, KeyStoreException, 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 pathcertificatePath- certificate file pathkeyPasswd- Password used to decrypt the key. May be null if the key is not encrypted.- Throws:
IOException- if any of files can not be readKeyStoreException- if private key can not be parsed or decryptedCertificateException- if certificate can not be parsed
-