Package io.netty.handler.ssl
Class PemPrivateKey
- java.lang.Object
-
- io.netty.util.AbstractReferenceCounted
-
- io.netty.handler.ssl.PemPrivateKey
-
- All Implemented Interfaces:
ByteBufHolder,PemEncoded,ReferenceCounted,java.io.Serializable,java.security.Key,java.security.PrivateKey,javax.security.auth.Destroyable
public final class PemPrivateKey extends AbstractReferenceCounted implements java.security.PrivateKey, PemEncoded
This is a special purpose implementation of aPrivateKeywhich allows the user to pass PEM/PKCS#8 encoded key material straight intoOpenSslContextwithout having to parse and re-encode bytes in Java land. All methods other than what's implemented inPemEncodedandDestroyablethrowUnsupportedOperationExceptions.- See Also:
PemEncoded,OpenSslContext,valueOf(byte[]),valueOf(ByteBuf), Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static byte[]BEGIN_PRIVATE_KEYprivate ByteBufcontentprivate static byte[]END_PRIVATE_KEYprivate static java.lang.StringPKCS8_FORMATprivate static longserialVersionUID
-
Constructor Summary
Constructors Modifier Constructor Description privatePemPrivateKey(ByteBuf content)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteBufcontent()Return the data which is held by thisByteBufHolder.PemPrivateKeycopy()Creates a deep copy of thisByteBufHolder.protected voiddeallocate()Called onceAbstractReferenceCounted.refCnt()is equals 0.voiddestroy()NOTE: This is a JDK8 interface/method.PemPrivateKeyduplicate()Duplicates thisByteBufHolder.java.lang.StringgetAlgorithm()byte[]getEncoded()java.lang.StringgetFormat()booleanisDestroyed()NOTE: This is a JDK8 interface/method.booleanisSensitive()Returnstrueif the PEM encoded value is considered sensitive information such as a private key.PemPrivateKeyreplace(ByteBuf content)Returns a newByteBufHolderwhich contains the specifiedcontent.PemPrivateKeyretain()Increases the reference count by1.PemPrivateKeyretain(int increment)Increases the reference count by the specifiedincrement.PemPrivateKeyretainedDuplicate()Duplicates thisByteBufHolder.(package private) static PemEncodedtoPEM(ByteBufAllocator allocator, boolean useDirect, byte[] bytes)(package private) static PemEncodedtoPEM(ByteBufAllocator allocator, boolean useDirect, java.security.PrivateKey key)Creates aPemEncodedvalue from thePrivateKey.PemPrivateKeytouch()Records the current access location of this object for debugging purposes.PemPrivateKeytouch(java.lang.Object hint)Records the current access location of this object with an additional arbitrary information for debugging purposes.static PemPrivateKeyvalueOf(byte[] key)Creates aPemPrivateKeyfrom rawbyte[].static PemPrivateKeyvalueOf(ByteBuf key)Creates aPemPrivateKeyfrom rawByteBuf.-
Methods inherited from class io.netty.util.AbstractReferenceCounted
refCnt, release, release, setRefCnt
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty.util.ReferenceCounted
refCnt, release, release
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
BEGIN_PRIVATE_KEY
private static final byte[] BEGIN_PRIVATE_KEY
-
END_PRIVATE_KEY
private static final byte[] END_PRIVATE_KEY
-
PKCS8_FORMAT
private static final java.lang.String PKCS8_FORMAT
- See Also:
- Constant Field Values
-
content
private final ByteBuf content
-
-
Constructor Detail
-
PemPrivateKey
private PemPrivateKey(ByteBuf content)
-
-
Method Detail
-
toPEM
static PemEncoded toPEM(ByteBufAllocator allocator, boolean useDirect, java.security.PrivateKey key)
Creates aPemEncodedvalue from thePrivateKey.
-
toPEM
static PemEncoded toPEM(ByteBufAllocator allocator, boolean useDirect, byte[] bytes)
-
valueOf
public static PemPrivateKey valueOf(byte[] key)
Creates aPemPrivateKeyfrom rawbyte[]. ATTENTION: It's assumed that the given argument is a PEM/PKCS#8 encoded value. No input validation is performed to validate it.
-
valueOf
public static PemPrivateKey valueOf(ByteBuf key)
Creates aPemPrivateKeyfrom rawByteBuf. ATTENTION: It's assumed that the given argument is a PEM/PKCS#8 encoded value. No input validation is performed to validate it.
-
isSensitive
public boolean isSensitive()
Description copied from interface:PemEncodedReturnstrueif the PEM encoded value is considered sensitive information such as a private key.- Specified by:
isSensitivein interfacePemEncoded
-
content
public ByteBuf content()
Description copied from interface:ByteBufHolderReturn the data which is held by thisByteBufHolder.- Specified by:
contentin interfaceByteBufHolder
-
copy
public PemPrivateKey copy()
Description copied from interface:ByteBufHolderCreates a deep copy of thisByteBufHolder.- Specified by:
copyin interfaceByteBufHolder- Specified by:
copyin interfacePemEncoded
-
duplicate
public PemPrivateKey duplicate()
Description copied from interface:ByteBufHolderDuplicates thisByteBufHolder. Be aware that this will not automatically callByteBufHolder.retain().- Specified by:
duplicatein interfaceByteBufHolder- Specified by:
duplicatein interfacePemEncoded
-
retainedDuplicate
public PemPrivateKey retainedDuplicate()
Description copied from interface:ByteBufHolderDuplicates thisByteBufHolder. This method returns a retained duplicate unlikeByteBufHolder.duplicate().- Specified by:
retainedDuplicatein interfaceByteBufHolder- Specified by:
retainedDuplicatein interfacePemEncoded- See Also:
ByteBuf.retainedDuplicate()
-
replace
public PemPrivateKey replace(ByteBuf content)
Description copied from interface:ByteBufHolderReturns a newByteBufHolderwhich contains the specifiedcontent.- Specified by:
replacein interfaceByteBufHolder- Specified by:
replacein interfacePemEncoded
-
touch
public PemPrivateKey touch()
Description copied from interface:ReferenceCountedRecords the current access location of this object for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you viaResourceLeakDetector. This method is a shortcut totouch(null).- Specified by:
touchin interfaceByteBufHolder- Specified by:
touchin interfacePemEncoded- Specified by:
touchin interfaceReferenceCounted- Overrides:
touchin classAbstractReferenceCounted
-
touch
public PemPrivateKey touch(java.lang.Object hint)
Description copied from interface:ReferenceCountedRecords the current access location of this object with an additional arbitrary information for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you viaResourceLeakDetector.- Specified by:
touchin interfaceByteBufHolder- Specified by:
touchin interfacePemEncoded- Specified by:
touchin interfaceReferenceCounted
-
retain
public PemPrivateKey retain()
Description copied from interface:ReferenceCountedIncreases the reference count by1.- Specified by:
retainin interfaceByteBufHolder- Specified by:
retainin interfacePemEncoded- Specified by:
retainin interfaceReferenceCounted- Overrides:
retainin classAbstractReferenceCounted
-
retain
public PemPrivateKey retain(int increment)
Description copied from interface:ReferenceCountedIncreases the reference count by the specifiedincrement.- Specified by:
retainin interfaceByteBufHolder- Specified by:
retainin interfacePemEncoded- Specified by:
retainin interfaceReferenceCounted- Overrides:
retainin classAbstractReferenceCounted
-
deallocate
protected void deallocate()
Description copied from class:AbstractReferenceCountedCalled onceAbstractReferenceCounted.refCnt()is equals 0.- Specified by:
deallocatein classAbstractReferenceCounted
-
getEncoded
public byte[] getEncoded()
- Specified by:
getEncodedin interfacejava.security.Key
-
getAlgorithm
public java.lang.String getAlgorithm()
- Specified by:
getAlgorithmin interfacejava.security.Key
-
getFormat
public java.lang.String getFormat()
- Specified by:
getFormatin interfacejava.security.Key
-
destroy
public void destroy()
NOTE: This is a JDK8 interface/method. Due to backwards compatibility reasons it's not possible to slap the@Overrideannotation onto this method.- Specified by:
destroyin interfacejavax.security.auth.Destroyable- See Also:
Destroyable.destroy()
-
isDestroyed
public boolean isDestroyed()
NOTE: This is a JDK8 interface/method. Due to backwards compatibility reasons it's not possible to slap the@Overrideannotation onto this method.- Specified by:
isDestroyedin interfacejavax.security.auth.Destroyable- See Also:
Destroyable.isDestroyed()
-
-