Class ASN1Type

java.lang.Object
org.apache.harmony.security.asn1.ASN1Type
All Implemented Interfaces:
ASN1Constants
Direct Known Subclasses:
ASN1Any, ASN1Choice, ASN1Constructed, ASN1Implicit, ASN1Primitive, ASN1StringType

public abstract class ASN1Type
extends Object
implements ASN1Constants
This abstract class is the super class for all ASN.1 types
See Also:
ASN.1
  • Field Details

    • id

      public final int id
      Integer representation of primitive identifier.
    • constrId

      public final int constrId
      Integer representation of constructed identifier.
  • Constructor Details

    • ASN1Type

      public ASN1Type​(int tagNumber)
      Constructs a primitive, universal ASN.1 type.
      Parameters:
      tagNumber - - ASN.1 tag number
      Throws:
      IllegalArgumentException - - if tagNumber is invalid
    • ASN1Type

      public ASN1Type​(int tagClass, int tagNumber)
      Constructs an ASN.1 type.
      Parameters:
      tagClass - - tag class. MUST be CLASS_UNIVERSAL, CLASS_APPLICATION, CLASS_CONTEXTSPECIFIC, CLASS_PRIVATE
      tagNumber - - ASN.1 tag number.
      Throws:
      IllegalArgumentException - - if tagClass or tagNumber is invalid
  • Method Details

    • decode

      public final Object decode​(byte[] encoded) throws IOException
      Throws:
      IOException
    • decode

      public final Object decode​(byte[] encoded, int offset, int encodingLen) throws IOException
      Throws:
      IOException
    • decode

      public final Object decode​(InputStream in) throws IOException
      Throws:
      IOException
    • verify

      public final void verify​(byte[] encoded) throws IOException
      Throws:
      IOException
    • verify

      public final void verify​(InputStream in) throws IOException
      Throws:
      IOException
    • encode

      public final byte[] encode​(Object object)
    • decode

      public abstract Object decode​(BerInputStream in) throws IOException
      Decodes ASN.1 type.
      Throws:
      IOException - if an I/O error occurs or the end of the stream is reached
    • checkTag

      public abstract boolean checkTag​(int identifier)
      Tests provided identifier.
      Parameters:
      identifier - identifier to be verified
      Returns:
      true if identifier is associated with this ASN.1 type
    • getDecodedObject

      protected Object getDecodedObject​(BerInputStream in) throws IOException
      Creates decoded object. Derived classes should override this method to provide creation for a selected class of objects during decoding. The default implementation returns an object created by decoding stream.
      Throws:
      IOException
    • encodeASN

      public abstract void encodeASN​(BerOutputStream out)
      Encodes ASN.1 type.
    • encodeContent

      public abstract void encodeContent​(BerOutputStream out)
    • setEncodingContent

      public abstract void setEncodingContent​(BerOutputStream out)
    • getEncodedLength

      public int getEncodedLength​(BerOutputStream out)
    • toString

      public String toString()
      Description copied from class: Object
      Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:
         getClass().getName() + '@' + Integer.toHexString(hashCode())

      See Writing a useful toString method if you intend implementing your own toString method.

      Overrides:
      toString in class Object
      Returns:
      a printable representation of this object.