@ThreadSafety(level=NOT_THREADSAFE) public final class X509PEMFileReader extends java.lang.Object implements java.io.Closeable
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BEGIN_CERTIFICATE_HEADER
The header string that should appear on a line by itself before the
base64-encoded representation of the bytes that comprise an X.509
certificate.
|
static java.lang.String |
END_CERTIFICATE_FOOTER
The footer string that should appear on a line by itself after the
base64-encoded representation of the bytes that comprise an X.509
certificate.
|
Constructor and Description |
---|
X509PEMFileReader(java.io.File pemFile)
Creates a new X.509 PEM file reader that will read certificate information
from the specified file.
|
X509PEMFileReader(java.io.InputStream inputStream)
Creates a new X.509 PEM file reader that will read certificate information
from the provided input stream.
|
X509PEMFileReader(java.lang.String pemFilePath)
Creates a new X.509 PEM file reader that will read certificate information
from the specified file.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this X.509 PEM file reader.
|
X509Certificate |
readCertificate()
Reads the next certificate from the PEM file.
|
@NotNull public static final java.lang.String BEGIN_CERTIFICATE_HEADER
@NotNull public static final java.lang.String END_CERTIFICATE_FOOTER
public X509PEMFileReader(@NotNull java.lang.String pemFilePath) throws java.io.IOException
pemFilePath
- The path to the PEM file from which the certificates
should be read. This must not be null
and the
file must exist.java.io.IOException
- If a problem occurs while attempting to open the file
for reading.public X509PEMFileReader(@NotNull java.io.File pemFile) throws java.io.IOException
pemFile
- The PEM file from which the certificates should be read.
This must not be null
and the file must
exist.java.io.IOException
- If a problem occurs while attempting to open the file
for reading.public X509PEMFileReader(@NotNull java.io.InputStream inputStream)
inputStream
- The input stream from which the certificates should
be read. This must not be null
and it must be
open for reading.@Nullable public X509Certificate readCertificate() throws java.io.IOException, CertException
null
if the end of the
file has been reached.java.io.IOException
- If a problem occurs while trying to read data from
the PEM file.CertException
- If a problem occurs while trying to interpret data
read from the PEM file as an X.509 certificate.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
- If a problem is encountered while attempting to close
the reader.