codec.x509
Class X509Extension

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.ArrayList
                    |
                    +--codec.asn1.ASN1AbstractCollection
                          |
                          +--codec.asn1.ASN1Sequence
                                |
                                +--codec.x509.X509Extension
All Implemented Interfaces:
ASN1Collection, ASN1Type, Cloneable, Collection, Externalizable, List, Serializable, X509Extension
Direct Known Subclasses:
AdmissionExtension, ArchiveCutoffExtension, AuthorityInfoAccessExtension, AuthorityKeyIdentifierExtension, BasicConstraintsExtension, CertHashExtension, CertificateIssuerExtension, CertificatePoliciesExtension, CRLDistributionPointsExtension, DateOfCreationExtension, IssuingDistPoint, QCStatementExtension, ReasonCodeExtension, RestrictionExtension, SubjectKeyIdentifierExtension, ValidityModelExtension

public class X509Extension
extends ASN1Sequence
implements X509Extension, Externalizable

This class represents an X.509 extension of this form

 Extension  ::=  SEQUENCE  {
  extnID      OBJECT IDENTIFIER,
  critical    BOOLEAN DEFAULT FALSE,
  extnValue   OCTET STRING
 }
 
Creation date: (18.08.99 15:23:09)

Author:
Markus Tak
See Also:
Serialized Form

Field Summary
protected  ASN1Boolean critical
           
protected  ASN1ObjectIdentifier extnID
           
protected  ASN1OctetString extnValue
           
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
X509Extension()
          Creates an instance ready for use in decoding extensions.
X509Extension(ASN1ObjectIdentifier theoid, boolean crit, ASN1Type val)
          This constructor fills-up the data structure.
X509Extension(byte[] b)
          Initializes this extension from the given DER code.
 
Method Summary
protected  void decodeExtensionValue(ASN1Type t)
          This method allows to decode the extension value based on an ASN.1 template.
 Set getCriticalExtensionOIDs()
          From interface java.security.cert.X509Extension.
 byte[] getEncoded()
          Returns the DER encoding of this extension.
 byte[] getExtensionValue(String oid)
          From java.security.cert.X509Extension.
 Set getNonCriticalExtensionOIDs()
           
 ASN1ObjectIdentifier getOID()
          Returns the OID of this extension
 Object getValue()
          Returns this extension's value.
 boolean hasUnsupportedCriticalExtension()
          From java.security.cert.X509Extension
 boolean isCritical()
          Returns the critical flag of this extension
 void setCritical(boolean ncrit)
          Set the critical of this extension
 void setOID(ASN1ObjectIdentifier noid)
          Set this extension's OID
 void setValue(ASN1Type nval)
          Set this extension's value
 String toString()
          Returns a human-readable String representation of this extension
 String toString(String offset)
          Returns a human-readable String representation of this extension with an offset String.
 
Methods inherited from class codec.asn1.ASN1Sequence
getTag
 
Methods inherited from class codec.asn1.ASN1AbstractCollection
checkConstraints, decode, encode, getCollection, getConstraint, getTagClass, isExplicit, isOptional, isType, readExternal, setConstraint, setExplicit, setOptional, writeExternal
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, remove, removeAll, retainAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
 
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList
 

Field Detail

extnID

protected ASN1ObjectIdentifier extnID

critical

protected ASN1Boolean critical

extnValue

protected ASN1OctetString extnValue
Constructor Detail

X509Extension

public X509Extension()
Creates an instance ready for use in decoding extensions.

X509Extension

public X509Extension(byte[] b)
              throws ASN1Exception,
                     IOException
Initializes this extension from the given DER code.
Parameters:
b - The DER code.
Throws:
ASN1Exception - iff the data cannot be decoded correctly.

X509Extension

public X509Extension(ASN1ObjectIdentifier theoid,
                     boolean crit,
                     ASN1Type val)
              throws Exception
This constructor fills-up the data structure.
Parameters:
theoid - This extension's OID
crit - TRUE if this extension shall be critical
val - The value of this extension as a ASN1Type. This one will be DER-encoded and be put into an ASN1OctetString
Method Detail

getCriticalExtensionOIDs

public Set getCriticalExtensionOIDs()
From interface java.security.cert.X509Extension.
Specified by:
getCriticalExtensionOIDs in interface X509Extension
Returns:
either an empty Set if this extension is not critical or a Set containing one element (this extension's OID) if this extension is marked as critical.

getEncoded

public byte[] getEncoded()
                  throws CertificateEncodingException
Returns the DER encoding of this extension. From java.security.cert.X509Extension
Returns:
a byte array containing the DER-encoding of this extension

getExtensionValue

public byte[] getExtensionValue(String oid)
From java.security.cert.X509Extension. Returns the DER encoding of this extension if the given OID matches
Specified by:
getExtensionValue in interface X509Extension
Parameters:
oid - the OID to search for
Returns:
a byte array containing the DER-encoding of this extension

getNonCriticalExtensionOIDs

public Set getNonCriticalExtensionOIDs()
Specified by:
getNonCriticalExtensionOIDs in interface X509Extension

getOID

public ASN1ObjectIdentifier getOID()
Returns the OID of this extension
Returns:
This extension's OID

getValue

public Object getValue()
Returns this extension's value. The value is tried to be decoded and returned as a ASN1Type object. If decoding fails for some reason (e.g. extension did not contain a DER encoded ASN.1 type, the ASN1OctetString containing the original value is returned.
Overrides:
getValue in class ASN1AbstractCollection
Following copied from class: codec.asn1.ASN1AbstractCollection
Returns:
The collection used internally for storing the elements in this constructed ASN.1 type.

decodeExtensionValue

protected void decodeExtensionValue(ASN1Type t)
                             throws ASN1Exception,
                                    IOException
This method allows to decode the extension value based on an ASN.1 template. This implicitly checks the syntax of the decoded type.

hasUnsupportedCriticalExtension

public boolean hasUnsupportedCriticalExtension()
From java.security.cert.X509Extension
Specified by:
hasUnsupportedCriticalExtension in interface X509Extension
Returns:
always false

isCritical

public boolean isCritical()
Returns the critical flag of this extension
Returns:
true if this extension is marked as critical

setCritical

public void setCritical(boolean ncrit)
Set the critical of this extension
Parameters:
ncrit - true if this extension shall be marked critical

setOID

public void setOID(ASN1ObjectIdentifier noid)
            throws ConstraintException
Set this extension's OID
Parameters:
noid - this extension's new OID

setValue

public void setValue(ASN1Type nval)
              throws CertificateEncodingException
Set this extension's value
Parameters:
nval - the new value of this extension. Note that this value will be DER-encoded and stored inside an ASN1OctetString
Throws:
CertificateEncodingException - if encoding fails

toString

public String toString()
Returns a human-readable String representation of this extension
Overrides:
toString in class ASN1AbstractCollection
Following copied from class: codec.asn1.ASN1AbstractCollection
Returns:
The string representation of this ASN.1 collection.

toString

public String toString(String offset)
Returns a human-readable String representation of this extension with an offset String.
Parameters:
offset - String that will be put before each line of output


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.