Class Asn1Object


  • @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
    public class Asn1Object
    extends Object
    An ASN.1 TLV. The object is not parsed. It can only handle integers and strings.
    Author:
    zhang
    • Field Detail

      • type

        protected final int type
      • length

        protected final int length
      • value

        protected final byte[] value
      • tag

        protected final int tag
    • Constructor Detail

      • Asn1Object

        public Asn1Object​(int tag,
                          int length,
                          byte[] value)
        Construct a ASN.1 TLV. The TLV could be either a constructed or primitive entity.

        The first byte in DER encoding is made of following fields,

        -------------------------------------------------
        |Bit 8|Bit 7|Bit 6|Bit 5|Bit 4|Bit 3|Bit 2|Bit 1|
        -------------------------------------------------
        |  Class    | CF  |     +      Type             |
        -------------------------------------------------
         
        • Class: Universal, Application, Context or Private
        • CF: Constructed flag. If 1, the field is constructed.
        • Type: This is actually called tag in ASN.1. It indicates data type (Integer, String) or a construct (sequence, choice, set).
        Parameters:
        tag - Tag or Identifier
        length - Length of the field
        value - Encoded octet string for the field.
    • Method Detail

      • getType

        public int getType()
      • getLength

        public int getLength()
      • getValue

        public byte[] getValue()
      • isConstructed

        public boolean isConstructed()
      • getParser

        public DerParser getParser()
                            throws IOException
        For constructed field, return a parser for its content.
        Returns:
        A parser for the construct.
        Throws:
        IOException - if problems parsing
      • getString

        public String getString()
                         throws IOException
        Get value as string. Most strings are treated as Latin-1.
        Returns:
        value as string
        Throws:
        IOException - if problems parsing