public class Extension
extends java.lang.Object
implements java.security.cert.Extension, com.tencent.kona.sun.security.util.DerEncoder
Extensions are additional attributes which can be inserted in a X509 v3 certificate. For example a "Driving License Certificate" could have the driving license number as a extension.
Extensions are represented as a sequence of the extension identifier (Object Identifier), a boolean flag stating whether the extension is to be treated as being critical and the extension value itself (this is again a DER encoding of the extension value).
ASN.1 definition of Extension:
Extension ::= SEQUENCE {
ExtensionId OBJECT IDENTIFIER,
critical BOOLEAN DEFAULT FALSE,
extensionValue OCTET STRING
}
All subclasses need to implement a constructor of the form
<subclass> (Boolean, Object)
where the Object is typically an array of DER encoded bytes.| Modifier and Type | Field and Description |
|---|---|
protected boolean |
critical |
protected com.tencent.kona.sun.security.util.ObjectIdentifier |
extensionId |
protected byte[] |
extensionValue |
| Constructor and Description |
|---|
Extension()
Default constructor.
|
Extension(com.tencent.kona.sun.security.util.DerValue derVal)
Constructs an extension from a DER encoded array of bytes.
|
Extension(Extension ext)
Constructs an Extension from another extension.
|
Extension(com.tencent.kona.sun.security.util.ObjectIdentifier extensionId,
boolean critical,
byte[] extensionValue)
Constructs an Extension from individual components of ObjectIdentifier,
criticality and the DER encoded OctetString.
|
| Modifier and Type | Method and Description |
|---|---|
void |
encode(com.tencent.kona.sun.security.util.DerOutputStream out)
Write the extension to the DerOutputStream.
|
void |
encode(java.io.OutputStream out)
Implementing
Extension.encode(OutputStream). |
boolean |
equals(java.lang.Object other)
Compares this Extension for equality with the specified
object.
|
com.tencent.kona.sun.security.util.ObjectIdentifier |
getExtensionId()
Returns the ObjectIdentifier of the extension.
|
byte[] |
getExtensionValue()
Returns the extension value as a byte array for further processing.
|
java.lang.String |
getId() |
java.lang.String |
getName()
Returns the extension name.
|
byte[] |
getValue() |
int |
hashCode()
Returns a hashcode value for this Extension.
|
boolean |
isCritical()
Returns true if extension is critical.
|
static Extension |
newExtension(com.tencent.kona.sun.security.util.ObjectIdentifier extensionId,
boolean critical,
byte[] rawExtensionValue)
Constructs an Extension from individual components of ObjectIdentifier,
criticality and the raw encoded extension value.
|
java.lang.String |
toString()
Returns the Extension in user readable form.
|
protected com.tencent.kona.sun.security.util.ObjectIdentifier extensionId
protected boolean critical
protected byte[] extensionValue
public Extension()
public Extension(com.tencent.kona.sun.security.util.DerValue derVal)
throws java.io.IOException
java.io.IOExceptionpublic Extension(com.tencent.kona.sun.security.util.ObjectIdentifier extensionId,
boolean critical,
byte[] extensionValue)
throws java.io.IOException
extensionId - the ObjectIdentifier of the extensioncritical - the boolean indicating if the extension is criticalextensionValue - the DER encoded octet string of the value.java.io.IOExceptionpublic Extension(Extension ext)
ext - the extension to create from.public static Extension newExtension(com.tencent.kona.sun.security.util.ObjectIdentifier extensionId, boolean critical, byte[] rawExtensionValue) throws java.io.IOException
extensionId - the ObjectIdentifier of the extensioncritical - the boolean indicating if the extension is criticalrawExtensionValue - the raw DER-encoded extension value (this
is not the encoded OctetString).java.io.IOExceptionpublic final void encode(java.io.OutputStream out)
throws java.io.IOException
Extension.encode(OutputStream).
This implementation is made final to make sure all encode()
methods in child classes are actually implementations of
encode(DerOutputStream) below.encode in interface java.security.cert.Extensionout - the output streamjava.io.IOExceptionpublic void encode(com.tencent.kona.sun.security.util.DerOutputStream out)
encode in interface com.tencent.kona.sun.security.util.DerEncoderout - the DerOutputStream to write the extension to.public boolean isCritical()
isCritical in interface java.security.cert.Extensionpublic com.tencent.kona.sun.security.util.ObjectIdentifier getExtensionId()
public byte[] getValue()
getValue in interface java.security.cert.Extensionpublic byte[] getExtensionValue()
public java.lang.String getName()
public java.lang.String getId()
getId in interface java.security.cert.Extensionpublic java.lang.String toString()
toString in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object other)
other object is an
instanceof Extension, then
its encoded form is retrieved and compared with the
encoded form of this Extension.equals in class java.lang.Objectother - the object to test for equality with this Extension.