issrg.ac
Class Extension

java.lang.Object
  extended by issrg.ac.Extension
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
AttributeAuthorityInformationAccess, AuthorityAttributeIdentifier, AuthorityInformationAccess, BasicAttConstraint, IndirectIssuer, IssuedOnBehalfOf, NoAssertion, NoRevocation, WebdavCertificate, WebdavRevocation

public class Extension
extends java.lang.Object
implements java.lang.Cloneable

This is the class representing the Extension ASN.1 construct. It contains an OCTET_STRING of the extension value, but the derived classes may parse that value to represent a meaningful structure instead, but they don't need to worry about encoding the value as OCTET_STRING.


Field Summary
protected  boolean critical
           
protected  java.lang.String extnID
           
protected static NULL Null
           
protected  ASN1Object theObject
           
 
Constructor Summary
protected Extension()
           
  Extension(Extension e)
          This constructor creates a copy of the given Extension.
  Extension(java.lang.String extnID, boolean critical)
          This constructor builds an Extension with no value set.
  Extension(java.lang.String extnID, boolean critical, OCTET_STRING extnValue)
          This constructor builds an Extension given the OID of the extension, its criticality flag and the ASN1Object of the Extension Value.
 
Method Summary
 java.lang.Object clone()
           
 void decode(ASN1Object ao)
          This method decodes a given ASN1Object.
 void decodeValue(ASN1Object ao)
          This method decodes the Extension Value.
 ASN1Object encodeValue()
          This method encodes the extension value to the ASN1Object representing the encoding of the extension value and returns it.
 java.lang.String extensionValueToString(java.lang.String indent)
          This method returns the String representation of the extension value.
 java.lang.String getExtensionOID()
          Returns the OID of the extension in the dotted form.
 OCTET_STRING getExtensionValue()
          Returns the OCTET STRING of the extnValue.
 boolean isCritical()
          Returns true if the extension is critical.
 void setCritical(boolean critical)
          Sets the flag if the extension is critical.
 void setExtensionOID(java.lang.String oid)
          Sets the OID of the extension in the dotted form.
 void setExtensionValue(OCTET_STRING value)
          Sets the string of octets containing the extension value.
 ASN1Object toASN1Object()
          This method returns the ASN1Object of the Extension.
 java.lang.String toString()
           
 java.lang.String toString(java.lang.String ident)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

extnID

protected java.lang.String extnID

critical

protected boolean critical

theObject

protected ASN1Object theObject

Null

protected static final NULL Null
Constructor Detail

Extension

protected Extension()

Extension

public Extension(Extension e)
This constructor creates a copy of the given Extension.

Parameters:
e - - the Extension to copy

Extension

public Extension(java.lang.String extnID,
                 boolean critical)
This constructor builds an Extension with no value set.

Parameters:
extnID - - the OID of the Extension
critical - - the criticality flag; if true, the extension will be marked critical; otherwise non-critical

Extension

public Extension(java.lang.String extnID,
                 boolean critical,
                 OCTET_STRING extnValue)
          throws CodingException
This constructor builds an Extension given the OID of the extension, its criticality flag and the ASN1Object of the Extension Value.

Parameters:
extnID - - the OID of the extension
critical - - the criticality flag; if true, the extension is critical
extnValue - - the OCTET_STRING of the extension value; can be null;
Throws:
CodingException
Method Detail

getExtensionOID

public java.lang.String getExtensionOID()
Returns the OID of the extension in the dotted form.


setExtensionOID

public void setExtensionOID(java.lang.String oid)
Sets the OID of the extension in the dotted form.


isCritical

public boolean isCritical()
Returns true if the extension is critical.


setCritical

public void setCritical(boolean critical)
Sets the flag if the extension is critical.


getExtensionValue

public final OCTET_STRING getExtensionValue()
                                     throws CodingException
Returns the OCTET STRING of the extnValue. This method calls encodeValue() to get the ASN1Object of the value, which is then DER-encoded and the encoding is converted into OCTET STRING.

The descendant classes should override encodeValue() method to return the correct ASN1Object representing the extension value.

Throws:
CodingException

setExtensionValue

public final void setExtensionValue(OCTET_STRING value)
                             throws CodingException
Sets the string of octets containing the extension value. This method uses BER decoder to decode the bytes of the OCTET STRING, then the resulting ASN1Object is passed to decodeValue() method.

The subclasses should override decodeValue() method to fill the extension with meaning.

Throws:
CodingException

toASN1Object

public ASN1Object toASN1Object()
                        throws CodingException
This method returns the ASN1Object of the Extension. It is a SEQUENCE of ObjectID, criticality flag (if critical), and the OCTET STRING of the extension value, as returned by getExtensionValue() method (which uses encodeValue()).

Throws:
CodingException

decode

public void decode(ASN1Object ao)
            throws CodingException
This method decodes a given ASN1Object. It must be a SEQUENCE of ObjectID, boolean criticality flag, and the Extension value, which is passed to setExtensionValue() method (which in its turn calls decodeValue() method).

Throws:
CodingException

decodeValue

public void decodeValue(ASN1Object ao)
                 throws CodingException
This method decodes the Extension Value. By default it does not do anything.

Override this method so that your Extension decodes what you want to fill in its internal fields.

Parameters:
ao - - the ASN1Object obtained by BER-decoding the bytes of the extension value OCTET STRING
Throws:
CodingException

encodeValue

public ASN1Object encodeValue()
                       throws CodingException
This method encodes the extension value to the ASN1Object representing the encoding of the extension value and returns it. By default it returns the contents of the Extension that were received in decodeValue.

Override this method so that your Extension returns what you want.

Returns:
ASN1Object, which will be subsequently DER-encoded and the bytes of that encoding will be converted into OCTET STRING of the extension value
Throws:
CodingException

extensionValueToString

public java.lang.String extensionValueToString(java.lang.String indent)
This method returns the String representation of the extension value. By default it calls toString() method on extnValue object.

Override this method if you need more user-friendly output of your custom extension value.

Parameters:
indent - - the indentation to use at the beginning of each line to make the text human-friendly

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(java.lang.String ident)

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object