Class ASN1OctetString

    • Constructor Detail

      • ASN1OctetString

        public ASN1OctetString()
        Creates a new ASN.1 octet string element with the default BER type and no value.
      • ASN1OctetString

        public ASN1OctetString​(byte type)
        Creates a new ASN.1 octet string element with the specified type and no value.
        Parameters:
        type - The BER type to use for this element.
      • ASN1OctetString

        public ASN1OctetString​(byte[] value)
        Creates a new ASN.1 octet string element with the default BER type and the provided value.
        Parameters:
        value - The value to use for this element.
      • ASN1OctetString

        public ASN1OctetString​(byte[] value,
                               int offset,
                               int length)
        Creates a new ASN.1 octet string element with the default BER type and the provided value.
        Parameters:
        value - The byte array containing the value to use for this element It must not be null.
        offset - The offset within the array at which the value begins. It must be greater than or equal to zero and less than or equal to the length of the array.
        length - The length in bytes of the value. It must be greater than or equal to zero, and it must not extend beyond the end of the array.
      • ASN1OctetString

        public ASN1OctetString​(byte type,
                               byte[] value)
        Creates a new ASN.1 octet string element with the specified type and the provided value.
        Parameters:
        type - The BER type to use for this element.
        value - The value to use for this element.
      • ASN1OctetString

        public ASN1OctetString​(byte type,
                               byte[] value,
                               int offset,
                               int length)
        Creates a new ASN.1 octet string element with the specified type and the provided value.
        Parameters:
        type - The BER type to use for this element.
        value - The byte array containing the value to use for this element. It must not be null.
        offset - The offset within the array at which the value begins. It must be greater than or equal to zero and less than or equal to the length of the array..
        length - The length in bytes of the value. It must be greater than or equal to zero, and it must not extend beyond the end of the array.
      • ASN1OctetString

        public ASN1OctetString​(java.lang.String value)
        Creates a new ASN.1 octet string element with the default BER type and the provided value.
        Parameters:
        value - The value to use for this element.
      • ASN1OctetString

        public ASN1OctetString​(byte type,
                               java.lang.String value)
        Creates a new ASN.1 octet string element with the specified type and the provided value.
        Parameters:
        type - The BER type to use for this element.
        value - The value to use for this element.
    • Method Detail

      • getValueLength

        public int getValueLength()
        Retrieves the number of bytes contained in the value.
        Overrides:
        getValueLength in class ASN1Element
        Returns:
        The number of bytes contained in the value.
      • encodeTo

        public void encodeTo​(ByteStringBuffer buffer)
        Appends an encoded representation of this ASN.1 element to the provided buffer.
        Overrides:
        encodeTo in class ASN1Element
        Parameters:
        buffer - The buffer to which the encoded representation should be appended.
      • stringValue

        public java.lang.String stringValue()
        Retrieves the string value for this element.
        Specified by:
        stringValue in interface ByteString
        Returns:
        The String value for this element.
      • decodeAsOctetString

        public static ASN1OctetString decodeAsOctetString​(byte[] elementBytes)
                                                   throws ASN1Exception
        Decodes the contents of the provided byte array as an octet string element.
        Parameters:
        elementBytes - The byte array to decode as an ASN.1 octet string element.
        Returns:
        The decoded ASN.1 octet string element.
        Throws:
        ASN1Exception - If the provided array cannot be decoded as an octet string element.
      • decodeAsOctetString

        public static ASN1OctetString decodeAsOctetString​(ASN1Element element)
        Decodes the provided ASN.1 element as an octet string element.
        Parameters:
        element - The ASN.1 element to be decoded.
        Returns:
        The decoded ASN.1 octet string element.
      • appendValueTo

        public void appendValueTo​(ByteStringBuffer buffer)
        Appends the value of this ASN.1 octet string to the provided buffer.
        Specified by:
        appendValueTo in interface ByteString
        Parameters:
        buffer - The buffer to which the value is to be appended.
      • toString

        public void toString​(java.lang.StringBuilder buffer)
        Appends a string representation of the value for this ASN.1 element to the provided buffer.
        Overrides:
        toString in class ASN1Element
        Parameters:
        buffer - The buffer to which to append the information.