public class Extension
extends java.lang.Object
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
(Boolean, Object)
where the Object is typically an array of DER encoded bytes.
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
critical |
protected ObjectIdentifier |
extensionId |
protected byte[] |
extensionValue |
| Constructor and Description |
|---|
Extension()
Default constructor.
|
Extension(DerValue derVal)
Constructs an extension from a DER encoded array of bytes.
|
Extension(Extension ext)
Constructs an Extension from another extension.
|
Extension(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(DerOutputStream out)
Write the extension to the DerOutputStream.
|
boolean |
equals(java.lang.Object other)
Compares this Extension for equality with the specified
object.
|
ObjectIdentifier |
getExtensionId()
Returns the ObjectIdentifier of the extension.
|
byte[] |
getExtensionValue()
Returns the extension value as an byte array for further processing.
|
int |
hashCode()
Returns a hashcode value for this Extension.
|
boolean |
isCritical()
Returns true if extension is critical.
|
java.lang.String |
toString()
Returns the Extension in user readable form.
|
protected ObjectIdentifier extensionId
protected boolean critical
protected byte[] extensionValue
public Extension()
public Extension(DerValue derVal) throws java.io.IOException
java.io.IOExceptionpublic Extension(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 void encode(DerOutputStream out) throws java.io.IOException
out - the DerOutputStream to write the extension to.java.io.IOException - on encoding errorspublic boolean isCritical()
public ObjectIdentifier getExtensionId()
public byte[] getExtensionValue()
public 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.Copyright © 2020. All Rights Reserved.