Top Description Fields Constructors Methods
io.netty5.handler.ssl

public final Class PemPrivateKey

extends BufferHolder<PemPrivateKey>
implements PrivateKey, PemEncoded
Class Inheritance
All Implemented Interfaces
io.netty5.handler.ssl.PemEncoded, java.lang.AutoCloseable, java.security.PrivateKey, javax.security.auth.Destroyable, java.security.AsymmetricKey, java.security.Key, java.io.Serializable
Imports
io.netty5.buffer.Buffer, .BufferAllocator, .BufferHolder, .SensitiveBufferAllocator, javax.security.auth.Destroyable, java.security.PrivateKey

This is a special purpose implementation of a PrivateKey which allows the user to pass PEM/PKCS#8 encoded key material straight into OpenSslContext without having to parse and re-encode bytes in Java land.

All methods other than what's implemented in PemEncoded and Destroyable throw UnsupportedOperationExceptions.

See Also
PemEncoded, OpenSslContext, valueOf(byte[]), valueOf(Buffer)

Field Summary

Modifier and TypeField and Description
private static final byte[]
private static final byte[]
private static final String
private static final long

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Buffer
content()

Implements io.netty5.handler.ssl.PemEncoded.content.

Returns the Buffer with the PEM encoded contents of this value.
public PemPrivateKey
copy()

Implements io.netty5.handler.ssl.PemEncoded.copy.

Return a copy of this PEM encoded value.
public void
destroy()

Overrides default javax.security.auth.Destroyable.destroy.

Destroy this Object.
public String
getAlgorithm()

Implements java.security.Key.getAlgorithm.

Returns the standard algorithm name for this key.
public byte[]
getEncoded()

Implements java.security.Key.getEncoded.

Returns the key in its primary encoding format, or null if this key does not support encoding.
public String
getFormat()

Implements java.security.Key.getFormat.

Returns the name of the primary encoding format of this key, or null if this key does not support encoding.
public boolean
isDestroyed()

Overrides default javax.security.auth.Destroyable.isDestroyed.

Determine if this Object has been destroyed.
protected PemPrivateKey
receive(Buffer
The Buffer that is received by the recipient, and needs to be wrapped in a new BufferHolder instance.
buf
)

Implements abstract io.netty5.buffer.BufferHolder.receive.

Called when a sent BufferHolder is received by the recipient.
pack-priv static PemEncoded
toPEM(PrivateKey key)

Creates a PemEncoded value from the PrivateKey.

pack-priv static PemEncoded
toPEM(byte[] bytes)

public static PemPrivateKey
valueOf(byte[] key)

Creates a PemPrivateKey from raw byte[].

public static PemPrivateKey
valueOf(Buffer key)

Creates a PemPrivateKey from raw Buffer.

Inherited from io.netty5.buffer.BufferHolder:
closeequalsgetBuffergetBufferVolatilehashCodeisAccessiblereplaceBufferreplaceBufferVolatilesendtouch

Field Detail

BEGIN_PRIVATE_KEYback to summary
private static final byte[] BEGIN_PRIVATE_KEY
END_PRIVATE_KEYback to summary
private static final byte[] END_PRIVATE_KEY
PKCS8_FORMATback to summary
private static final String PKCS8_FORMAT
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.security.PrivateKey.serialVersionUID.

Constructor Detail

PemPrivateKeyback to summary
private PemPrivateKey(Buffer content)

Method Detail

contentback to summary
public Buffer content()

Implements io.netty5.handler.ssl.PemEncoded.content.

Doc from io.netty5.handler.ssl.PemEncoded.content.

Returns the Buffer with the PEM encoded contents of this value.

Note

The returned buffer should not be closed directly. Instead, close() should be called on this PEM encoded value instead.

Returns:Buffer

The underlying Buffer with the contents of this PEM encoded value.

Annotations
@Override
copyback to summary
public PemPrivateKey copy()

Implements io.netty5.handler.ssl.PemEncoded.copy.

Doc from io.netty5.handler.ssl.PemEncoded.copy.

Return a copy of this PEM encoded value.

Returns:PemPrivateKey

A new identical copy of this PEM encoded value.

Annotations
@Override
destroyback to summary
public void destroy()

Overrides default javax.security.auth.Destroyable.destroy.

Doc from javax.security.auth.Destroyable.destroy.

Destroy this Object.

Sensitive information associated with this Object is destroyed or cleared. Subsequent calls to certain methods on this Object will result in an IllegalStateException being thrown.

Annotations
@Override
getAlgorithmback to summary
public String getAlgorithm()

Implements java.security.Key.getAlgorithm.

Doc from java.security.Key.getAlgorithm.

Returns the standard algorithm name for this key. For example, "DSA" would indicate that this key is a DSA key. See the key related sections (KeyFactory, KeyGenerator, KeyPairGenerator, and SecretKeyFactory) in the Java Security Standard Algorithm Names Specification for information about standard key algorithm names.

Returns:String

the name of the algorithm associated with this key.

Annotations
@Override
getEncodedback to summary
public byte[] getEncoded()

Implements java.security.Key.getEncoded.

Doc from java.security.Key.getEncoded.

Returns the key in its primary encoding format, or null if this key does not support encoding.

Returns:byte[]

the encoded key, or null if the key does not support encoding.

Annotations
@Override
getFormatback to summary
public String getFormat()

Implements java.security.Key.getFormat.

Doc from java.security.Key.getFormat.

Returns the name of the primary encoding format of this key, or null if this key does not support encoding. The primary encoding format is named in terms of the appropriate ASN.1 data format, if an ASN.1 specification for this key exists. For example, the name of the ASN.1 data format for public keys is SubjectPublicKeyInfo, as defined by the X.509 standard; in this case, the returned format is "X.509". Similarly, the name of the ASN.1 data format for private keys is PrivateKeyInfo, as defined by the PKCS #8 standard; in this case, the returned format is "PKCS#8".

Returns:String

the primary encoding format of the key.

Annotations
@Override
isDestroyedback to summary
public boolean isDestroyed()

Overrides default javax.security.auth.Destroyable.isDestroyed.

Doc from javax.security.auth.Destroyable.isDestroyed.

Determine if this Object has been destroyed.

Returns:boolean

true if this Object has been destroyed, false otherwise.

Annotations
@Override
receiveback to summary
protected PemPrivateKey receive(Buffer buf)

Implements abstract io.netty5.buffer.BufferHolder.receive.

Doc from io.netty5.buffer.BufferHolder.receive.

Called when a sent BufferHolder is received by the recipient. The BufferHolder should return a new concrete instance, that wraps the given Buffer object.

Parameters
buf:Buffer

The Buffer that is received by the recipient, and needs to be wrapped in a new BufferHolder instance.

Returns:PemPrivateKey

A new buffer holder instance, containing the given buffer.

Annotations
@Override
toPEMback to summary
pack-priv static PemEncoded toPEM(PrivateKey key)

Creates a PemEncoded value from the PrivateKey.

toPEMback to summary
pack-priv static PemEncoded toPEM(byte[] bytes)
valueOfback to summary
public static PemPrivateKey valueOf(byte[] key)

Creates a PemPrivateKey from raw byte[]. ATTENTION: It's assumed that the given argument is a PEM/PKCS#8 encoded value. No input validation is performed to validate it.

valueOfback to summary
public static PemPrivateKey valueOf(Buffer key)

Creates a PemPrivateKey from raw Buffer. ATTENTION: It's assumed that the given argument is a PEM/PKCS#8 encoded value. No input validation is performed to validate it.