issrg.ac
Class Extensions

java.lang.Object
  extended by issrg.ac.Extensions
All Implemented Interfaces:
java.lang.Cloneable

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

This is the class that represents the Extensions ASN.1 construct. It has a vector of extensions.

This class also maintains a register of custom Extension subclasses that will be used to decode specific extensions, distinguished by their OID. When an Extension with a known OID is encountered, the corresponding class is instantiated by calling its constructor with a single ASN1Object argument. If no class is registered for such OID, or construction fails, an instance of Extension will be constructed.

See Also:
registerExtension(java.lang.String, java.lang.Class)

Field Summary
protected static java.util.Map registry
           
protected  java.util.Vector values
           
 
Constructor Summary
protected Extensions()
           
  Extensions(Extension extension)
          This constructor builds Extensions with a single Extension.
  Extensions(Extensions e)
          This constructor copies a given Extensions.
  Extensions(java.util.Vector values)
          This constructor creates Extensions from a Vector.
 
Method Summary
 java.lang.Object clone()
           
 void decode(ASN1Object ao)
          This method decodes a given ASN1Object.
 java.util.Vector getValues()
          Returns the set of Extensions.
static void registerExtension(java.lang.String oid, java.lang.Class extension)
          This method lets you register your extensions.
 void setValues(java.util.Vector values)
          Sets the set of Extensions.
 ASN1Object toASN1Object()
          This method returns the ASN1Object of Extensions.
 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

values

protected java.util.Vector values

registry

protected static java.util.Map registry
Constructor Detail

Extensions

protected Extensions()

Extensions

public Extensions(Extensions e)
This constructor copies a given Extensions.

Parameters:
e - - the Extensions to copy

Extensions

public Extensions(java.util.Vector values)
This constructor creates Extensions from a Vector. Each element must be a Extension subclass.

Parameters:
values - - a Vector of extensions; each element must be an Extension; cannot be null

Extensions

public Extensions(Extension extension)
This constructor builds Extensions with a single Extension.

Parameters:
extension - - the Extension
Method Detail

getValues

public java.util.Vector getValues()
Returns the set of Extensions. Never null, but can be empty.


setValues

public void setValues(java.util.Vector values)
Sets the set of Extensions. Cannot be null, but can be empty.


toASN1Object

public ASN1Object toASN1Object()
                        throws CodingException
This method returns the ASN1Object of Extensions.

Returns:
SEQUENCE of Extension
Throws:
CodingException

decode

public void decode(ASN1Object ao)
            throws CodingException
This method decodes a given ASN1Object. It must be a SEQUENCE of elements, each being a valid Extension.

It checks if the registry contains a class for the ObjectID of each extension in the list. If there is such class, it attempts to construct the Extension using a constructor of that class with a single ASN1Object argument to it. If this fails or there is no class registered for this ObjectID, an Extension is constructed.

Parameters:
ao - - the ASN1Object of Extensions
Throws:
CodingException

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

registerExtension

public static void registerExtension(java.lang.String oid,
                                     java.lang.Class extension)
This method lets you register your extensions. Now if an attribute with a particular OID will be encountered, it will be parsed by your code directly.

...
Extension.registerAttribute("1.2.3.4.5", MyCuteAttribute.class);

Now the constructor of your class will be invoked automatically whenever the OID is encountered in the attributes of an encoded AC.

Parameters:
oid - is the dotted form of the OID
extension - is the class of your attribute