Package org.gudy.bouncycastle.openssl
Class PEMReader
java.lang.Object
java.io.Reader
java.io.BufferedReader
org.gudy.bouncycastle.openssl.PEMReader
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Readable
Class for reading OpenSSL PEM encoded streams containing
X509 certificates, PKCS8 encoded keys and PKCS7 objects.
In the case of PKCS7 objects the reader will return a CMS ContentInfo object. Keys and Certificates will be returned using the appropriate java.security type.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new PEMReaderPEMReader
(Reader reader, PasswordFinder pFinder) Create a new PEMReader with a password finderPEMReader
(Reader reader, PasswordFinder pFinder, String provider) Create a new PEMReader with a password finder -
Method Summary
Modifier and TypeMethodDescriptionprivate X509AttributeCertificate
readAttributeCertificate
(String endMarker) Reads in a X509 Attribute Certificate.private byte[]
private X509Certificate
readCertificate
(String endMarker) Reads in a X509Certificate.private PKCS10CertificationRequest
readCertificateRequest
(String endMarker) Reads in a PKCS10 certification request.private X509CRL
Reads in a X509CRL.private ECNamedCurveParameterSpec
readECParameters
(String endMarker) private KeyPair
readECPrivateKey
(String endMarker) private KeyPair
readKeyPair
(String type, String endMarker) Read a Key Pairprivate ContentInfo
Reads in a PKCS7 object.private PublicKey
readPublicKey
(String endMarker) private PublicKey
readRSAPublicKey
(String endMarker) Methods inherited from class java.io.BufferedReader
close, lines, mark, markSupported, read, read, readLine, ready, reset, skip
Methods inherited from class java.io.Reader
nullReader, read, read, transferTo
-
Field Details
-
pFinder
-
provider
-
-
Constructor Details
-
PEMReader
Create a new PEMReader- Parameters:
reader
- the Reader
-
PEMReader
Create a new PEMReader with a password finder- Parameters:
reader
- the ReaderpFinder
- the password finder
-
PEMReader
Create a new PEMReader with a password finder- Parameters:
reader
- the ReaderpFinder
- the password finderprovider
- the cryptography provider to use
-
-
Method Details
-
readObject
- Throws:
IOException
-
readBytes
- Throws:
IOException
-
readRSAPublicKey
- Throws:
IOException
-
readPublicKey
- Throws:
IOException
-
readCertificate
Reads in a X509Certificate.- Returns:
- the X509Certificate
- Throws:
IOException
- if an I/O error occured
-
readCRL
Reads in a X509CRL.- Returns:
- the X509Certificate
- Throws:
IOException
- if an I/O error occured
-
readCertificateRequest
Reads in a PKCS10 certification request.- Returns:
- the certificate request.
- Throws:
IOException
- if an I/O error occured
-
readAttributeCertificate
Reads in a X509 Attribute Certificate.- Returns:
- the X509 Attribute Certificate
- Throws:
IOException
- if an I/O error occured
-
readPKCS7
Reads in a PKCS7 object. This returns a ContentInfo object suitable for use with the CMS API.- Returns:
- the X509Certificate
- Throws:
IOException
- if an I/O error occured
-
readKeyPair
Read a Key Pair- Throws:
Exception
-
readECParameters
- Throws:
IOException
-
readECPrivateKey
- Throws:
IOException
-