Class PEM
- All Implemented Interfaces:
BinaryEncodablePREVIEW
PEM is a preview API of the Java platform.
BinaryEncodablePREVIEW 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)PREVIEW
and PEMDecoder.decode(InputStream)PREVIEW 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)PREVIEW
or PEMDecoder.decode(InputStream, Class)PREVIEW with PEM.class as the
type.
A PEM object can be encoded to its textual representation by
invoking toString() or by using PEMEncoderPREVIEW.
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.
- Since:
- 26
- External Specifications
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates aPEMinstance with the specified type and Base64-encoded content byte array.Creates aPEMinstance with the specified type and Base64-encoded content and leading data as byte arrays.Creates aPEMinstance with the specified type and Base64-encoded content string.Creates aPEMinstance with the specified type, Base64-encoded content string, and leading data byte array. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]content()Returns the Base64-encoded content.byte[]decode()Returns the Base64-decoded content as a byte array, usingBase64.getMimeDecoder().byte[]Returns the leading data that preceded the PEM header in the decoded input.toString()Returns a PEM string representation of this object, usingtypefor the header and footer lines andcontentfor the Base64 body.type()Returns the PEM type identifier.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Constructor Details
-
PEM
Creates aPEMinstance with the specified type, Base64-encoded content string, and leading data byte array.- Parameters:
type- the PEM type identifier; must not contain PEM encapsulation syntaxbase64Content- the Base64-encoded content, excluding the PEM header and footerleadingData- data that precedes the PEM header. This array is defensively copied.- Throws:
IllegalArgumentException- iftypecontains PEM encapsulation syntaxNullPointerException- if any parameter isnull
-
PEM
Creates aPEMinstance with the specified type and Base64-encoded content string.- Parameters:
type- the PEM type identifier; must not contain PEM encapsulation syntaxbase64Content- the Base64-encoded content, excluding the PEM header and footer- Throws:
IllegalArgumentException- iftypecontains PEM encapsulation syntaxNullPointerException- if any parameter isnull
-
PEM
Creates aPEMinstance with the specified type and Base64-encoded content and leading data as byte arrays.- Parameters:
type- the PEM type identifier; must not contain PEM encapsulation syntaxbase64Content- the Base64-encoded content, excluding the PEM header and footer. This array is defensively copied.leadingData- data that precedes the PEM header. This array is defensively copied.- Throws:
IllegalArgumentException- iftypecontains PEM encapsulation syntaxNullPointerException- if any parameter isnull- Since:
- 27
-
PEM
Creates aPEMinstance with the specified type and Base64-encoded content byte array.- Parameters:
type- the PEM type identifier; must not contain PEM encapsulation syntaxbase64Content- the Base64-encoded content, excluding the PEM header and footer. This array is defensively copied.- Throws:
IllegalArgumentException- iftypecontains PEM encapsulation syntaxNullPointerException- if any parameter isnull- Since:
- 27
-
-
Method Details
-
type
-
leadingData
public byte[] leadingData()Returns the leading data that preceded the PEM header in the decoded input.- Returns:
- a newly-allocated byte array containing leading data, or
nullif no leading data is present
-
content
public byte[] content()Returns the Base64-encoded content.- Returns:
- a newly-allocated byte array containing the Base64 content
- Since:
- 27
-
decode
public byte[] decode()Returns the Base64-decoded content as a byte array, usingBase64.getMimeDecoder().- Returns:
- a newly-allocated byte array containing the decoded content
- Throws:
IllegalArgumentException- if decoding fails
-
toString
-
PEMwhen preview features are enabled.