Class Asn1Encodeable

java.lang.Object
org.apache.kerby.asn1.type.Asn1Object
org.apache.kerby.asn1.type.Asn1Encodeable
All Implemented Interfaces:
Asn1Type
Direct Known Subclasses:
AbstractAsn1Type

public abstract class Asn1Encodeable extends Asn1Object implements Asn1Type
The abstract ASN1 object for all the ASN1 types. It provides basic encoding and decoding utilities.
  • Field Details

    • bodyLength

      protected int bodyLength
    • outerEncodeable

      public Asn1Encodeable outerEncodeable
  • Constructor Details

    • Asn1Encodeable

      public Asn1Encodeable(Tag tag)
      Constructor with a tag
      Parameters:
      tag - The tag
    • Asn1Encodeable

      public Asn1Encodeable(UniversalTag tag)
      Default constructor with an universal tag.
      Parameters:
      tag - the tag
    • Asn1Encodeable

      public Asn1Encodeable(int tag)
      Constructor with a tag
      Parameters:
      tag - The tag
  • Method Details

    • usePrimitive

      public void usePrimitive(boolean isPrimitive)
      Description copied from interface: Asn1Type
      Use primitive or constructed.
      Specified by:
      usePrimitive in interface Asn1Type
      Overrides:
      usePrimitive in class Asn1Object
    • isPrimitive

      public boolean isPrimitive()
      Description copied from interface: Asn1Type
      Tells if it is PRIMITIVE or not.
      Specified by:
      isPrimitive in interface Asn1Type
      Overrides:
      isPrimitive in class Asn1Object
      Returns:
      true if using PRIMITIVE, false otherwise
    • useDefinitiveLength

      public void useDefinitiveLength(boolean isDefinitiveLength)
      Description copied from interface: Asn1Type
      Use definitive length or not. Note definitive length only makes sense when it's constructed.
      Specified by:
      useDefinitiveLength in interface Asn1Type
    • isDefinitiveLength

      public boolean isDefinitiveLength()
      Description copied from interface: Asn1Type
      Tells if it's definitive length or not.
      Specified by:
      isDefinitiveLength in interface Asn1Type
      Returns:
      The boolean value
    • useImplicit

      public void useImplicit(boolean isImplicit)
      Description copied from interface: Asn1Type
      Use implicit or not.
      Specified by:
      useImplicit in interface Asn1Type
    • isImplicit

      public boolean isImplicit()
      Description copied from interface: Asn1Type
      Tells if it's is IMPLICIT or not.
      Specified by:
      isImplicit in interface Asn1Type
      Returns:
      true if using IMPLICIT, false otherwise
    • useDER

      public void useDER()
      Description copied from interface: Asn1Type
      Set encoding type as DER.
      Specified by:
      useDER in interface Asn1Type
    • isDER

      public boolean isDER()
      Description copied from interface: Asn1Type
      Tells if it's is DER
      Specified by:
      isDER in interface Asn1Type
      Returns:
      true if using DER, false otherwise
    • useBER

      public void useBER()
      Description copied from interface: Asn1Type
      Set encoding type as BER.
      Specified by:
      useBER in interface Asn1Type
    • isBER

      public boolean isBER()
      Description copied from interface: Asn1Type
      Tells if it's is BER
      Specified by:
      isBER in interface Asn1Type
      Returns:
      true if using BER, false otherwise
    • useCER

      public void useCER()
      Description copied from interface: Asn1Type
      Set encoding type as CER.
      Specified by:
      useCER in interface Asn1Type
    • isCER

      public boolean isCER()
      Description copied from interface: Asn1Type
      Tells if it's is CER
      Specified by:
      isCER in interface Asn1Type
      Returns:
      true if using CER, false otherwise
    • encode

      public byte[] encode() throws IOException
      Description copied from interface: Asn1Type
      Encode the type, by recursively.
      Specified by:
      encode in interface Asn1Type
      Returns:
      encoded bytes
      Throws:
      IOException
    • encode

      public void encode(ByteBuffer buffer) throws IOException
      Description copied from interface: Asn1Type
      Encode the type, by recursively, using the provided buffer.
      Specified by:
      encode in interface Asn1Type
      Parameters:
      buffer - The byte buffer
      Throws:
      IOException
    • resetBodyLength

      public void resetBodyLength()
    • encodeBody

      protected void encodeBody(ByteBuffer buffer) throws IOException
      Throws:
      IOException
    • decode

      public void decode(byte[] content) throws IOException
      Description copied from interface: Asn1Type
      Decode the content bytes into this type.
      Specified by:
      decode in interface Asn1Type
      Parameters:
      content - The content bytes
      Throws:
      IOException - e
    • encodingLength

      public int encodingLength()
      Description copied from interface: Asn1Type
      Get length of encoding bytes by just calculating without real encoding. Generally it's called to prepare for the encoding buffer.
      Specified by:
      encodingLength in interface Asn1Type
      Returns:
      length of encoding bytes
    • getHeaderLength

      protected int getHeaderLength()
      Specified by:
      getHeaderLength in class Asn1Object
    • getBodyLength

      protected int getBodyLength()
      Specified by:
      getBodyLength in class Asn1Object
    • encodingHeaderLength

      protected int encodingHeaderLength() throws IOException
      Throws:
      IOException
    • encodingBodyLength

      protected abstract int encodingBodyLength() throws IOException
      Throws:
      IOException
    • decode

      public void decode(ByteBuffer content) throws IOException
      Description copied from interface: Asn1Type
      Decode the content bytes into this type.
      Specified by:
      decode in interface Asn1Type
      Parameters:
      content - The content bytes
      Throws:
      IOException - e
    • decode

      public void decode(Asn1ParseResult parseResult) throws IOException
      Throws:
      IOException
    • decodeBody

      protected abstract void decodeBody(Asn1ParseResult parseResult) throws IOException
      Throws:
      IOException
    • taggedEncodingLength

      protected int taggedEncodingLength(TaggingOption taggingOption)
    • taggedEncode

      public byte[] taggedEncode(TaggingOption taggingOption) throws IOException
      Description copied from interface: Asn1Type
      Tag and encode this type using the provided tagging option.
      Specified by:
      taggedEncode in interface Asn1Type
      Parameters:
      taggingOption - The tagging option
      Returns:
      encoded bytes
      Throws:
      IOException
    • taggedEncode

      public void taggedEncode(ByteBuffer buffer, TaggingOption taggingOption) throws IOException
      Description copied from interface: Asn1Type
      Tag and encode this type using the provided tagging option.
      Specified by:
      taggedEncode in interface Asn1Type
      Parameters:
      buffer - The byte buffer
      taggingOption - The tagging option
      Throws:
      IOException
    • taggedDecode

      public void taggedDecode(byte[] content, TaggingOption taggingOption) throws IOException
      Description copied from interface: Asn1Type
      Decode the content bytes into this type as it's tagged with the provided tagging option. See TaggingOption
      Specified by:
      taggedDecode in interface Asn1Type
      Parameters:
      content - The content bytes
      taggingOption - The tagging option
      Throws:
      IOException - e
    • taggedDecode

      public void taggedDecode(ByteBuffer content, TaggingOption taggingOption) throws IOException
      Description copied from interface: Asn1Type
      Decode the content bytes into this type as it's tagged with the provided tagging option. See TaggingOption
      Specified by:
      taggedDecode in interface Asn1Type
      Parameters:
      content - The content bytes
      taggingOption - The tagging option
      Throws:
      IOException - e
    • taggedDecode

      public void taggedDecode(Asn1ParseResult parseResult, TaggingOption taggingOption) throws IOException
      Throws:
      IOException