Record Class PEM
- Record Components:
type- the type identifier from the PEM header, without PEM syntax labels; for example, for a public key,typewould be "PUBLIC KEY"content- the Base64-encoded data, excluding the PEM header and footerleadingData- any non-PEM data that precedes the PEM header during decoding. This value may benull.
- All Implemented Interfaces:
DEREncodablePREVIEW
PEM is a preview API of the Java platform.
PEM is a DEREncodablePREVIEW that represents Privacy-Enhanced
Mail (PEM) data by its type and Base64-encoded content.
The PEMDecoder.decode(String)PREVIEW and
PEMDecoder.decode(InputStream)PREVIEW methods return a PEM object
when the data type cannot be represented by a cryptographic object.
If you need access to the leading data of a PEM text, or want to
handle the text content directly, use the decoding methods
PEMDecoder.decode(String, Class)PREVIEW or
PEMDecoder.decode(InputStream, Class)PREVIEW with PEM.class as an
argument type.
A PEM object can be encoded back to its textual format by calling
toString() or by using the encode methods in PEMEncoderPREVIEW.
When constructing a PEM instance, both type and
content must not be null.
No validation is performed during instantiation to ensure that
type conforms to RFC 7468 or other legacy formats, that
content is valid Base64 data, or that content matches the
type.
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.
leadingData is null if there is no data preceding the PEM
header during decoding. leadingData can be useful for reading
metadata that accompanies the PEM data. Because the value may represent a large
amount of data, it is not defensively copied by the constructor, and the
leadingData() method does not return a clone. Modification of the
passed-in or returned array changes the value stored in this record.
- Since:
- 26
- External Specifications
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncontent()Returns the value of thecontentrecord component.final byte[]decode()Returns a Base64-decoded byte array ofcontent, usingBase64.getMimeDecoder().final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.byte[]Returns the value of theleadingDatarecord component.final StringtoString()Returns the PEM formatted string containing thetypeand Base64-encodedcontent.type()Returns the value of thetyperecord component.Methods declared in class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Creates and returns a copy of this object.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.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 parameters.- Parameters:
type- the PEM type identifiercontent- the Base64-encoded data, excluding the PEM header and footerleadingData- any non-PEM data read during the decoding process before the PEM header. This value may benull.- Throws:
IllegalArgumentException- iftypeis incorrectly formattedNullPointerException- iftypeorcontentisnull
-
PEM
Creates aPEMinstance with the specified type and content. This constructor setsleadingDatatonull.- Parameters:
type- the PEM type identifiercontent- the Base64-encoded data, excluding the PEM header and footer- Throws:
IllegalArgumentException- iftypeis incorrectly formattedNullPointerException- iftypeorcontentisnull
-
-
Method Details
-
toString
-
decode
public final byte[] decode()Returns a Base64-decoded byte array ofcontent, usingBase64.getMimeDecoder().- Returns:
- a decoded byte array
- Throws:
IllegalArgumentException- if decoding fails
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
type
-
content
-
leadingData
public byte[] leadingData()Returns the value of theleadingDatarecord component.- Returns:
- the value of the
leadingDatarecord component
-
PEMwhen preview features are enabled.