Preview
Third Preview of PEM Encodings of Cryptographic Objects (JEP 538).
Programs can only use PEM when preview features are enabled.
Preview features may be removed in a future release,
or upgraded to permanent features of the Java platform.
BinaryEncodable representing a Privacy-Enhanced Mail (PEM) structure
composed of a type identifier, Base64-encoded content, and optional
leading data that precedes the PEM header.
The type is the label in the PEM header, following the
BEGIN keyword and excluding the encapsulation boundaries.
Common type values include, but are not limited to:
CERTIFICATE, CERTIFICATE REQUEST, ATTRIBUTE CERTIFICATE, X509 CRL, PKCS7,
CMS, PRIVATE KEY, ENCRYPTED PRIVATE KEY, and PUBLIC KEY.
Instances of this class are returned by PEMDecoder#decode(String)
and PEMDecoder#decode(InputStream) when the content cannot be represented
as a cryptographic object. To explicitly retrieve a PEM instance
with access to the leading data, use PEMDecoder#decode(String, Class)
or PEMDecoder#decode(InputStream, Class) with PEM.class as the
type.
A PEM object can be encoded to its textual representation by
invoking toString() or by using PEMEncoder.
To construct a PEM instance, type and
base64Content must be non-null. For constructors that accept
leadingData, it must also be non-null.
No validation is performed to ensure that the type conforms to
RFC 7468 or legacy formats, or that the content corresponds to the declared
type.
PEMDecoder, PEMEncoder
| Modifier and Type | Field and Description |
|---|---|
| private final byte[] | |
| private byte[] | |
| private final String |
| Access | Constructor and Description |
|---|---|
| public | PEM(String
the PEM type identifier; must not contain PEM encapsulation
syntax type, String the Base64-encoded content, excluding the PEM header
and footer base64Content, byte[] data that precedes the PEM header.
This array is defensively copied. leadingData)Creates a |
| public | |
| public | PEM(String
the PEM type identifier; must not contain PEM encapsulation
syntax type, byte[] the Base64-encoded content, excluding the PEM header
and footer. This array is defensively copied. base64Content, byte[] data that precedes the PEM header.
This array is defensively copied. leadingData)Creates a |
| public |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | |
| public byte[] | Returns: a newly-allocated byte array containing the Base64 contentReturns the Base64-encoded content. |
| public byte[] | Returns: a newly-allocated byte array containing the decoded contentReturns the Base64-decoded content as a byte array, using
|
| public byte[] | Returns: a newly-allocated byte array containing leading data, ornull if no leading data is presentReturns the leading data that preceded the PEM header in the decoded input. |
| public String | Returns: the PEM-formatted stringOverrides java. Returns a PEM string representation of this object, using |
| pack-priv byte[] | |
| public String |
| content | back to summary |
|---|---|
| private final byte[] content | |
| leadingData | back to summary |
|---|---|
| private byte[] leadingData | |
| type | back to summary |
|---|---|
| private final String type | |
| PEM | back to summary |
|---|---|
| public PEM(String type, String base64Content, byte[] leadingData) Creates a
| |
| PEM | back to summary |
|---|---|
| public PEM(String type, String base64Content) Creates a
| |
| PEM | back to summary |
|---|---|
| public PEM(String type, byte[] base64Content, byte[] leadingData) Creates a
| |
| PEM | back to summary |
|---|---|
| public PEM(String type, byte[] base64Content) Creates a
| |
| clear | back to summary |
|---|---|
| pack-priv void clear() | |
| content | back to summary |
|---|---|
| public byte[] content() Returns the Base64-encoded content.
| |
| decode | back to summary |
|---|---|
| public byte[] decode() Returns the Base64-decoded content as a byte array, using
| |
| leadingData | back to summary |
|---|---|
| public byte[] leadingData() Returns the leading data that preceded the PEM header in the decoded input.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a PEM string representation of this object, using | |
| toTextualByteArray | back to summary |
|---|---|
| pack-priv byte[] toTextualByteArray() | |
| type | back to summary |
|---|---|
| public String type() Returns the PEM type identifier.
| |