public class Extension
extends java.lang.Object
implements java.io.Serializable
Extensions are addiitonal 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 }
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 |
clearValue() |
void |
encode(DerOutputStream out)
Write the extension to the DerOutputStream.
|
ObjectIdentifier |
getExtensionId()
Returns the ObjectIdentifier of the extension.
|
byte[] |
getExtensionValue()
Returns the extension value as an byte array for further processing.
|
boolean |
isCritical()
Returns true if extension is critical.
|
void |
setCritical(boolean c) |
void |
setExtensionId(ObjectIdentifier oid) |
void |
setExtensionValue(byte[] value) |
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.IOException
public 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.IOException
public 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 void setCritical(boolean c)
public void clearValue()
public ObjectIdentifier getExtensionId()
public void setExtensionId(ObjectIdentifier oid)
public byte[] getExtensionValue()
public void setExtensionValue(byte[] value)
public java.lang.String toString()
toString
in class java.lang.Object