Package io.netty.handler.ssl
Class PemX509Certificate
- java.lang.Object
-
- java.security.cert.Certificate
-
- java.security.cert.X509Certificate
-
- io.netty.handler.ssl.PemX509Certificate
-
- All Implemented Interfaces:
ByteBufHolder,PemEncoded,ReferenceCounted,java.io.Serializable,java.security.cert.X509Extension
public final class PemX509Certificate extends java.security.cert.X509Certificate implements PemEncoded
This is a special purpose implementation of aX509Certificatewhich allows the user to pass PEM/PKCS#8 encoded data straight intoOpenSslContextwithout having to parse and re-encode bytes in Java land. All methods other than what's implemented inPemEncoded's throwUnsupportedOperationExceptions.- See Also:
PemEncoded,OpenSslContext,valueOf(byte[]),valueOf(ByteBuf), Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static byte[]BEGIN_CERTprivate ByteBufcontentprivate static byte[]END_CERT
-
Constructor Summary
Constructors Modifier Constructor Description privatePemX509Certificate(ByteBuf content)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static ByteBufappend(ByteBufAllocator allocator, boolean useDirect, PemEncoded encoded, int count, ByteBuf pem)Appends thePemEncodedvalue to theByteBuf(last arg) and returns it.private static ByteBufappend(ByteBufAllocator allocator, boolean useDirect, java.security.cert.X509Certificate cert, int count, ByteBuf pem)Appends theX509Certificatevalue to theByteBuf(last arg) and returns it.voidcheckValidity()voidcheckValidity(java.util.Date date)ByteBufcontent()Return the data which is held by thisByteBufHolder.PemX509Certificatecopy()Creates a deep copy of thisByteBufHolder.PemX509Certificateduplicate()Duplicates thisByteBufHolder.booleanequals(java.lang.Object o)intgetBasicConstraints()java.util.Set<java.lang.String>getCriticalExtensionOIDs()byte[]getEncoded()byte[]getExtensionValue(java.lang.String oid)java.security.PrincipalgetIssuerDN()boolean[]getIssuerUniqueID()boolean[]getKeyUsage()java.util.Set<java.lang.String>getNonCriticalExtensionOIDs()java.util.DategetNotAfter()java.util.DategetNotBefore()java.security.PublicKeygetPublicKey()java.math.BigIntegergetSerialNumber()java.lang.StringgetSigAlgName()java.lang.StringgetSigAlgOID()byte[]getSigAlgParams()byte[]getSignature()java.security.PrincipalgetSubjectDN()boolean[]getSubjectUniqueID()byte[]getTBSCertificate()intgetVersion()inthashCode()booleanhasUnsupportedCriticalExtension()booleanisSensitive()Returnstrueif the PEM encoded value is considered sensitive information such as a private key.private static ByteBufnewBuffer(ByteBufAllocator allocator, boolean useDirect, int initialCapacity)intrefCnt()Returns the reference count of this object.booleanrelease()Decreases the reference count by1and deallocates this object if the reference count reaches at0.booleanrelease(int decrement)Decreases the reference count by the specifieddecrementand deallocates this object if the reference count reaches at0.PemX509Certificatereplace(ByteBuf content)Returns a newByteBufHolderwhich contains the specifiedcontent.PemX509Certificateretain()Increases the reference count by1.PemX509Certificateretain(int increment)Increases the reference count by the specifiedincrement.PemX509CertificateretainedDuplicate()Duplicates thisByteBufHolder.(package private) static PemEncodedtoPEM(ByteBufAllocator allocator, boolean useDirect, java.security.cert.X509Certificate... chain)Creates aPemEncodedvalue from theX509Certificates.java.lang.StringtoString()PemX509Certificatetouch()Records the current access location of this object for debugging purposes.PemX509Certificatetouch(java.lang.Object hint)Records the current access location of this object with an additional arbitrary information for debugging purposes.static PemX509CertificatevalueOf(byte[] key)Creates aPemX509Certificatefrom rawbyte[].static PemX509CertificatevalueOf(ByteBuf key)Creates aPemX509Certificatefrom rawByteBuf.voidverify(java.security.PublicKey key)voidverify(java.security.PublicKey key, java.lang.String sigProvider)
-
-
-
Field Detail
-
BEGIN_CERT
private static final byte[] BEGIN_CERT
-
END_CERT
private static final byte[] END_CERT
-
content
private final ByteBuf content
-
-
Constructor Detail
-
PemX509Certificate
private PemX509Certificate(ByteBuf content)
-
-
Method Detail
-
toPEM
static PemEncoded toPEM(ByteBufAllocator allocator, boolean useDirect, java.security.cert.X509Certificate... chain) throws java.security.cert.CertificateEncodingException
Creates aPemEncodedvalue from theX509Certificates.- Throws:
java.security.cert.CertificateEncodingException
-
append
private static ByteBuf append(ByteBufAllocator allocator, boolean useDirect, PemEncoded encoded, int count, ByteBuf pem)
Appends thePemEncodedvalue to theByteBuf(last arg) and returns it. If theByteBufdidn't exist yet it'll create it using theByteBufAllocator.
-
append
private static ByteBuf append(ByteBufAllocator allocator, boolean useDirect, java.security.cert.X509Certificate cert, int count, ByteBuf pem) throws java.security.cert.CertificateEncodingException
Appends theX509Certificatevalue to theByteBuf(last arg) and returns it. If theByteBufdidn't exist yet it'll create it using theByteBufAllocator.- Throws:
java.security.cert.CertificateEncodingException
-
newBuffer
private static ByteBuf newBuffer(ByteBufAllocator allocator, boolean useDirect, int initialCapacity)
-
valueOf
public static PemX509Certificate valueOf(byte[] key)
Creates aPemX509Certificatefrom 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 PemX509Certificate valueOf(ByteBuf key)
Creates aPemX509Certificatefrom 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
-
refCnt
public int refCnt()
Description copied from interface:ReferenceCountedReturns the reference count of this object. If0, it means this object has been deallocated.- Specified by:
refCntin interfaceReferenceCounted
-
content
public ByteBuf content()
Description copied from interface:ByteBufHolderReturn the data which is held by thisByteBufHolder.- Specified by:
contentin interfaceByteBufHolder
-
copy
public PemX509Certificate copy()
Description copied from interface:ByteBufHolderCreates a deep copy of thisByteBufHolder.- Specified by:
copyin interfaceByteBufHolder- Specified by:
copyin interfacePemEncoded
-
duplicate
public PemX509Certificate 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 PemX509Certificate 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 PemX509Certificate replace(ByteBuf content)
Description copied from interface:ByteBufHolderReturns a newByteBufHolderwhich contains the specifiedcontent.- Specified by:
replacein interfaceByteBufHolder- Specified by:
replacein interfacePemEncoded
-
retain
public PemX509Certificate retain()
Description copied from interface:ReferenceCountedIncreases the reference count by1.- Specified by:
retainin interfaceByteBufHolder- Specified by:
retainin interfacePemEncoded- Specified by:
retainin interfaceReferenceCounted
-
retain
public PemX509Certificate 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
-
touch
public PemX509Certificate 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
-
touch
public PemX509Certificate 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
-
release
public boolean release()
Description copied from interface:ReferenceCountedDecreases the reference count by1and deallocates this object if the reference count reaches at0.- Specified by:
releasein interfaceReferenceCounted- Returns:
trueif and only if the reference count became0and this object has been deallocated
-
release
public boolean release(int decrement)
Description copied from interface:ReferenceCountedDecreases the reference count by the specifieddecrementand deallocates this object if the reference count reaches at0.- Specified by:
releasein interfaceReferenceCounted- Returns:
trueif and only if the reference count became0and this object has been deallocated
-
getEncoded
public byte[] getEncoded()
- Specified by:
getEncodedin classjava.security.cert.Certificate
-
hasUnsupportedCriticalExtension
public boolean hasUnsupportedCriticalExtension()
- Specified by:
hasUnsupportedCriticalExtensionin interfacejava.security.cert.X509Extension
-
getCriticalExtensionOIDs
public java.util.Set<java.lang.String> getCriticalExtensionOIDs()
- Specified by:
getCriticalExtensionOIDsin interfacejava.security.cert.X509Extension
-
getNonCriticalExtensionOIDs
public java.util.Set<java.lang.String> getNonCriticalExtensionOIDs()
- Specified by:
getNonCriticalExtensionOIDsin interfacejava.security.cert.X509Extension
-
getExtensionValue
public byte[] getExtensionValue(java.lang.String oid)
- Specified by:
getExtensionValuein interfacejava.security.cert.X509Extension
-
checkValidity
public void checkValidity()
- Specified by:
checkValidityin classjava.security.cert.X509Certificate
-
checkValidity
public void checkValidity(java.util.Date date)
- Specified by:
checkValidityin classjava.security.cert.X509Certificate
-
getVersion
public int getVersion()
- Specified by:
getVersionin classjava.security.cert.X509Certificate
-
getSerialNumber
public java.math.BigInteger getSerialNumber()
- Specified by:
getSerialNumberin classjava.security.cert.X509Certificate
-
getIssuerDN
public java.security.Principal getIssuerDN()
- Specified by:
getIssuerDNin classjava.security.cert.X509Certificate
-
getSubjectDN
public java.security.Principal getSubjectDN()
- Specified by:
getSubjectDNin classjava.security.cert.X509Certificate
-
getNotBefore
public java.util.Date getNotBefore()
- Specified by:
getNotBeforein classjava.security.cert.X509Certificate
-
getNotAfter
public java.util.Date getNotAfter()
- Specified by:
getNotAfterin classjava.security.cert.X509Certificate
-
getTBSCertificate
public byte[] getTBSCertificate()
- Specified by:
getTBSCertificatein classjava.security.cert.X509Certificate
-
getSignature
public byte[] getSignature()
- Specified by:
getSignaturein classjava.security.cert.X509Certificate
-
getSigAlgName
public java.lang.String getSigAlgName()
- Specified by:
getSigAlgNamein classjava.security.cert.X509Certificate
-
getSigAlgOID
public java.lang.String getSigAlgOID()
- Specified by:
getSigAlgOIDin classjava.security.cert.X509Certificate
-
getSigAlgParams
public byte[] getSigAlgParams()
- Specified by:
getSigAlgParamsin classjava.security.cert.X509Certificate
-
getIssuerUniqueID
public boolean[] getIssuerUniqueID()
- Specified by:
getIssuerUniqueIDin classjava.security.cert.X509Certificate
-
getSubjectUniqueID
public boolean[] getSubjectUniqueID()
- Specified by:
getSubjectUniqueIDin classjava.security.cert.X509Certificate
-
getKeyUsage
public boolean[] getKeyUsage()
- Specified by:
getKeyUsagein classjava.security.cert.X509Certificate
-
getBasicConstraints
public int getBasicConstraints()
- Specified by:
getBasicConstraintsin classjava.security.cert.X509Certificate
-
verify
public void verify(java.security.PublicKey key)
- Specified by:
verifyin classjava.security.cert.Certificate
-
verify
public void verify(java.security.PublicKey key, java.lang.String sigProvider)- Specified by:
verifyin classjava.security.cert.Certificate
-
getPublicKey
public java.security.PublicKey getPublicKey()
- Specified by:
getPublicKeyin classjava.security.cert.Certificate
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.security.cert.Certificate
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.security.cert.Certificate
-
toString
public java.lang.String toString()
- Specified by:
toStringin classjava.security.cert.Certificate
-
-