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()Creates and returns a copy of this object.booleanIndicates whether some other object is "equal to" this one.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class<?> getClass()Returns the runtime class of thisObject.inthashCode()Returns a hash code value for this object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.final voidwait()Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
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.