APIdia Launch Partner
Top Description Fields Constructors Methods
sun.security.x509

public Class Extension

extends Object
implements Extension, DerEncoder
Class Inheritance
All Implemented Interfaces
sun.security.util.DerEncoder, java.security.cert.Extension
Known Direct Subclasses
sun.security.x509.InhibitAnyPolicyExtension, sun.security.x509.InvalidityDateExtension, sun.security.x509.IssuerAlternativeNameExtension, sun.security.x509.IssuingDistributionPointExtension, sun.security.x509.KeyUsageExtension, sun.security.x509.NameConstraintsExtension, sun.security.x509.NetscapeCertTypeExtension, sun.security.x509.OCSPNoCheckExtension, sun.security.x509.PolicyConstraintsExtension, sun.security.x509.PolicyMappingsExtension, sun.security.x509.PrivateKeyUsageExtension, sun.security.x509.SubjectAlternativeNameExtension, sun.security.x509.SubjectInfoAccessExtension, sun.security.x509.SubjectKeyIdentifierExtension, sun.security.x509.UnparseableExtension, sun.security.provider.certpath.OCSPNonceExtension, sun.security.x509.AuthorityInfoAccessExtension, sun.security.x509.AuthorityKeyIdentifierExtension, sun.security.x509.BasicConstraintsExtension, sun.security.x509.CertificateIssuerExtension, sun.security.x509.CertificatePoliciesExtension, sun.security.x509.CRLDistributionPointsExtension, sun.security.x509.CRLNumberExtension, sun.security.x509.CRLReasonCodeExtension, sun.security.x509.ExtendedKeyUsageExtension
Imports
java.io.IOException, .OutputStream, java.util.Arrays, .Objects, sun.security.util.*

Represent a X509 Extension Attribute.

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 an 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.
Authors
Amit Kapoor, Hemma Prafullchandra

Field Summary

Modifier and TypeField and Description
protected boolean
protected ObjectIdentifier
protected byte[]
private static final int

Constructor Summary

AccessConstructor and Description
public
Extension()

Default constructor.

public
Extension(DerValue derVal)

Constructs an extension from a DER encoded array of bytes.

public
Extension(ObjectIdentifier
the ObjectIdentifier of the extension
extensionId
,
boolean
the boolean indicating if the extension is critical
critical
,
byte[]
the DER encoded octet string of the value.
extensionValue
)

Constructs an Extension from individual components of ObjectIdentifier, criticality and the DER encoded OctetString.

public
Extension(Extension
the extension to create from.
ext
)

Constructs an Extension from another extension.

Method Summary

Modifier and TypeMethod and Description
public final void
public void
encode(DerOutputStream
the DerOutputStream to write the extension to.
out
)

Implements sun.security.util.DerEncoder.encode.

Write the extension to the DerOutputStream.

public boolean

Returns:

true iff the other object is of type Extension, and the criticality flag, object identifier and encoded extension value of the two Extensions match, false otherwise.
equals
(Object
the object to test for equality with this Extension.
other
)

Overrides java.lang.Object.equals.

Compares this Extension for equality with the specified object.

public ObjectIdentifier
getExtensionId()

Returns the ObjectIdentifier of the extension.

public byte[]
getExtensionValue()

Returns the extension value as a byte array for further processing.

public String
getId()

Implements java.security.cert.Extension.getId.

Gets the extensions's object identifier.

public String
getName()

Returns the extension name.

public byte[]
getValue()

Implements java.security.cert.Extension.getValue.

Gets the extensions's DER-encoded value.

public int

Returns:

a hashcode value for this Extension
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hashcode value for this Extension.

public boolean
isCritical()

Implements java.security.cert.Extension.isCritical.

Returns true if extension is critical.

public static Extension
newExtension(ObjectIdentifier
the ObjectIdentifier of the extension
extensionId
,
boolean
the boolean indicating if the extension is critical
critical
,
byte[]
the raw DER-encoded extension value (this is not the encoded OctetString).
rawExtensionValue
)

Constructs an Extension from individual components of ObjectIdentifier, criticality and the raw encoded extension value.

public String
toString()

Overrides java.lang.Object.toString.

Returns the Extension in user readable form.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

criticalback to summary
protected boolean critical
extensionIdback to summary
protected ObjectIdentifier extensionId
extensionValueback to summary
protected byte[] extensionValue
hashMagicback to summary
private static final int hashMagic

Constructor Detail

Extensionback to summary
public Extension()

Default constructor. Used only by subclasses.

Extensionback to summary
public Extension(DerValue derVal) throws IOException

Constructs an extension from a DER encoded array of bytes.

Extensionback to summary
public Extension(ObjectIdentifier extensionId, boolean critical, byte[] extensionValue) throws IOException

Constructs an Extension from individual components of ObjectIdentifier, criticality and the DER encoded OctetString.

Parameters
extensionId:ObjectIdentifier

the ObjectIdentifier of the extension

critical:boolean

the boolean indicating if the extension is critical

extensionValue:byte[]

the DER encoded octet string of the value.

Extensionback to summary
public Extension(Extension ext)

Constructs an Extension from another extension. To be used for creating decoded subclasses.

Parameters
ext:Extension

the extension to create from.

Method Detail

encodeback to summary
public final void encode(OutputStream out) throws IOException

Implements java.security.cert.Extension.encode.

Implementing java.security.cert.Extension#encode(OutputStream). This implementation is made final to make sure all encode() methods in child classes are actually implementations of encode(DerOutputStream) below.

Parameters
out:OutputStream

the output stream

Annotations
@Override
Exceptions
IOException:

Doc from java.security.cert.Extension.encode.

on encoding or output error.

encodeback to summary
public void encode(DerOutputStream out)

Implements sun.security.util.DerEncoder.encode.

Write the extension to the DerOutputStream.

Parameters
out:DerOutputStream

the DerOutputStream to write the extension to.

Annotations
@Override
equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Compares this Extension for equality with the specified object. If the other object is an instanceof Extension, then its encoded form is retrieved and compared with the encoded form of this Extension.

Parameters
other:Object

the object to test for equality with this Extension.

Returns:boolean

true iff the other object is of type Extension, and the criticality flag, object identifier and encoded extension value of the two Extensions match, false otherwise.

Annotations
@Override
getExtensionIdback to summary
public ObjectIdentifier getExtensionId()

Returns the ObjectIdentifier of the extension.

getExtensionValueback to summary
public byte[] getExtensionValue()

Returns the extension value as a byte array for further processing. Note, this is the raw DER value of the extension, not the DER encoded octet string which is in the certificate. This method does not return a clone; it is the responsibility of the caller to clone the array if necessary.

getIdback to summary
public String getId()

Implements java.security.cert.Extension.getId.

Doc from java.security.cert.Extension.getId.

Gets the extensions's object identifier.

getNameback to summary
public String getName()

Returns the extension name. The default implementation returns the string form of the extensionId. Known extensions should override this method to return a human readable name.

getValueback to summary
public byte[] getValue()

Implements java.security.cert.Extension.getValue.

Doc from java.security.cert.Extension.getValue.

Gets the extensions's DER-encoded value. Note, this is the bytes that are encoded as an OCTET STRING. It does not include the OCTET STRING tag and length.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns a hashcode value for this Extension.

Returns:int

a hashcode value for this Extension

Annotations
@Override
isCriticalback to summary
public boolean isCritical()

Implements java.security.cert.Extension.isCritical.

Returns true if extension is critical.

newExtensionback to summary
public static Extension newExtension(ObjectIdentifier extensionId, boolean critical, byte[] rawExtensionValue) throws IOException

Constructs an Extension from individual components of ObjectIdentifier, criticality and the raw encoded extension value.

Parameters
extensionId:ObjectIdentifier

the ObjectIdentifier of the extension

critical:boolean

the boolean indicating if the extension is critical

rawExtensionValue:byte[]

the raw DER-encoded extension value (this is not the encoded OctetString).

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns the Extension in user readable form.