Class UuidType

  • All Implemented Interfaces:
    DEREncoder

    public class UuidType
    extends AbstractDERType
    implements DEREncoder
    Converts UUIDs to and from their DER encoded format. See RFC 4122.
    • Field Detail

      • UUID_LENGTH

        private static final int UUID_LENGTH
        Number of bytes in a uuid.
        See Also:
        Constant Field Values
      • derItem

        private final byte[] derItem
        UUID to encode.
    • Constructor Detail

      • UuidType

        public UuidType​(UUID item)
        Creates a new uuid type.
        Parameters:
        item - to DER encode
      • UuidType

        public UuidType​(DERTag tag,
                        UUID item)
        Creates a new uuid type.
        Parameters:
        tag - der tag associated with this type
        item - to DER encode
        Throws:
        IllegalArgumentException - if the der tag is constructed
    • Method Detail

      • encode

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

        public static UUID decode​(DERBuffer encoded)
        Converts bytes in the buffer to a uuid by reading from the current position to the limit.
        Parameters:
        encoded - buffer containing DER-encoded data where the buffer is positioned at the start of uuid bytes and the limit is set beyond the last byte of uuid data.
        Returns:
        decoded bytes as a uuid.
      • readLong

        protected static long readLong​(DERBuffer buffer)
        Reads the next 8 bytes from the supplied buffer to create a long.
        Parameters:
        buffer - to read
        Returns:
        UUID component integer
      • toBytes

        public static byte[] toBytes​(UUID uuid)
        Converts the supplied uuid to a byte array.
        Parameters:
        uuid - to convert
        Returns:
        byte array