Class ASN1TaggedObject

All Implemented Interfaces:
ASN1TaggedObjectParser, DEREncodable, DERTags
Direct Known Subclasses:
DERTaggedObject

public abstract class ASN1TaggedObject extends ASN1Object implements ASN1TaggedObjectParser
ASN.1 TaggedObject - in ASN.1 nottation this is any object proceeded by a [n] where n is some number - these are assume to follow the construction rules (as with sequences).
  • Field Details

    • tagNo

      int tagNo
    • empty

      boolean empty
    • explicit

      boolean explicit
    • obj

  • Constructor Details

    • ASN1TaggedObject

      public ASN1TaggedObject(int tagNo, DEREncodable obj)
      Create a tagged object in the explicit style.
      Parameters:
      tagNo - the tag number for this object.
      obj - the tagged object.
    • ASN1TaggedObject

      public ASN1TaggedObject(boolean explicit, int tagNo, DEREncodable obj)
      Create a tagged object with the style given by the value of explicit.

      If the object implements ASN1Choice the tag style will always be changed to explicit in accordance with the ASN.1 encoding rules.

      Parameters:
      explicit - true if the object is explicitly tagged.
      tagNo - the tag number for this object.
      obj - the tagged object.
  • Method Details

    • getInstance

      public static ASN1TaggedObject getInstance(ASN1TaggedObject obj, boolean explicit)
    • getInstance

      public static ASN1TaggedObject getInstance(Object obj)
    • asn1Equals

      boolean asn1Equals(DERObject o)
      Specified by:
      asn1Equals in class ASN1Object
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in class ASN1Object
    • getTagNo

      public int getTagNo()
      Specified by:
      getTagNo in interface ASN1TaggedObjectParser
    • isExplicit

      public boolean isExplicit()
      return whether or not the object may be explicitly tagged.

      Note: if the object has been read from an input stream, the only time you can be sure if isExplicit is returning the true state of affairs is if it returns false. An implicitly tagged object may appear to be explicitly tagged, so you need to understand the context under which the reading was done as well, see getObject below.

    • isEmpty

      public boolean isEmpty()
    • getObject

      public DERObject getObject()
      return whatever was following the tag.

      Note: tagged objects are generally context dependent if you're trying to extract a tagged object you should be going via the appropriate getInstance method.

    • getObjectParser

      public DEREncodable getObjectParser(int tag, boolean isExplicit)
      Return the object held in this tagged object as a parser assuming it has the type of the passed in tag. If the object doesn't have a parser associated with it, the base object is returned.
      Specified by:
      getObjectParser in interface ASN1TaggedObjectParser
    • encode

      abstract void encode(DEROutputStream out) throws IOException
      Specified by:
      encode in class ASN1Object
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object