Class OctetStringType

  • All Implemented Interfaces:
    DEREncoder

    public class OctetStringType
    extends AbstractDERType
    implements DEREncoder
    Converts strings to and from their DER encoded format.
    Author:
    Middleware Services
    • Constructor Summary

      Constructors 
      Constructor Description
      OctetStringType​(byte[] item)
      Creates a new octet string type.
      OctetStringType​(java.lang.String item)
      Creates a new octet string type.
      OctetStringType​(DERTag tag, byte[] item)
      Creates a new octet string type.
      OctetStringType​(DERTag tag, java.lang.String item)
      Creates a new octet string type.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String decode​(DERBuffer encoded)
      Converts bytes in the buffer to a string by reading from the current position to the limit, which assumes the bytes of the string are in big-endian order.
      byte[] encode()
      Encode this object into it's DER type.
      static byte[] toBytes​(java.lang.String s)
      Converts the supplied string to a byte array using the UTF-8 encoding.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • OctetStringType

        public OctetStringType​(java.lang.String item)
        Creates a new octet string type.
        Parameters:
        item - to DER encode
      • OctetStringType

        public OctetStringType​(byte[] item)
        Creates a new octet string type.
        Parameters:
        item - to DER encode
      • OctetStringType

        public OctetStringType​(DERTag tag,
                               java.lang.String item)
        Creates a new octet string type.
        Parameters:
        tag - der tag associated with this type
        item - to DER encode
        Throws:
        java.lang.IllegalArgumentException - if the der tag is constructed
      • OctetStringType

        public OctetStringType​(DERTag tag,
                               byte[] item)
        Creates a new octet string type.
        Parameters:
        tag - der tag associated with this type
        item - to DER encode
        Throws:
        java.lang.IllegalArgumentException - if the der tag is constructed
    • Method Detail

      • encode

        public byte[] encode()
        Description copied from interface: DEREncoder
        Encode this object into it's DER type.
        Specified by:
        encode in interface DEREncoder
        Returns:
        DER encoded object
      • decode

        public static java.lang.String decode​(DERBuffer encoded)
        Converts bytes in the buffer to a string by reading from the current position to the limit, which assumes the bytes of the string are in big-endian order.
        Parameters:
        encoded - buffer containing DER-encoded data where the buffer is positioned at the start of string bytes and the limit is set beyond the last byte of string data.
        Returns:
        decoded bytes as an string
      • toBytes

        public static byte[] toBytes​(java.lang.String s)
        Converts the supplied string to a byte array using the UTF-8 encoding.
        Parameters:
        s - to convert
        Returns:
        byte array