Class AsnValue

java.lang.Object
net.aifusion.asn.AsnValue
Direct Known Subclasses:
BitStringValue, BMPStringValue, BooleanValue, EnumeratedValue, GeneralizedTimeValue, IA5StringValue, IntegerValue, LargeInteger, NoOpValue, NullValue, NumericStringValue, OctetStringValue, OidValue, PrintableStringValue, RealValue, RelativeOidValue, SequenceValue, SetValue, TaggedValue, UTCTimeValue, Utf8StringValue, VisibleStringValue

public abstract class AsnValue extends Object
Wrapper class for all ASN.1 values. This class manages the tag, and provides common methods used in subclasses, while individual subclasses handle the actual values.
Author:
Sharad Singhal
  • Method Details

    • getTag

      public Tag getTag()
      Get the ASN.1 predefined (UNIVERSAL) tag associated with this value
      Returns:
      - associated tag, if any. Null if the tag is context specific or not a pre-defined tag
    • getTagNumber

      public long getTagNumber()
      Get the value of the tag associated with this value
      Returns:
      - long value containing the tag number
    • getTagClass

      public TagClass getTagClass()
      Get the ASN.1 Tag class for this value
      Returns:
      - ASN.1 Tag Class
    • getTagEncoding

      public TagEncoding getTagEncoding()
      Get the ASN.1 Tag Encoding for this value
      Returns:
      - ASN.1 Tag Encoding
    • getLength

      public int getLength()
      Get the encoded length of this value
      Returns:
      - encoded length of the value
    • getEncodedValue

      public abstract byte[] getEncodedValue()
      Get the encoded value for this ASN.1 value. This method should be implemented by subclasses to provide the encoded ASN.1 value
      Returns:
      byte [] containing encoded value for this ASN.1 value (including tag, length, content)
    • create

      public static AsnValue create(byte[] buffer, int blen, int cursor)
      Create an ASN.1 value from a serialized value. This method dispatches the call to subclasses which should also implement the create method to construct and return the proper AsnValue.
      Parameters:
      buffer - - input buffer
      blen - - length of buffer
      cursor - - offset pointing to the first byte (tag) for the value
      Returns:
      - parsed ASN.1 value
    • toAsnString

      public String toAsnString(String prefix)
      Get a (semi) ASN.1 notation for this value.
      Parameters:
      prefix - - prefix to add to each line
      Returns:
      - string containing the ASN.1 value
    • toHex

      public static String toHex(byte[] bytes)
    • toHex

      public static String toHex(byte[] bytes, int start, int end)
    • toHex

      public static String toHex(byte b)
    • toHex

      public static String toHex(long value)