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 Summary

    Fields
    Modifier and Type
    Field
    Description
    private final byte[]
    UUID to encode.
    private static final int
    Number of bytes in a uuid.
  • Constructor Summary

    Constructors
    Constructor
    Description
    UuidType(UUID item)
    Creates a new uuid type.
    UuidType(DERTag tag, UUID item)
    Creates a new uuid type.
  • Method Summary

    Modifier and Type
    Method
    Description
    static UUID
    decode(DERBuffer encoded)
    Converts bytes in the buffer to a uuid by reading from the current position to the limit.
    byte[]
    Encode this object into it's DER type.
    protected static long
    Reads the next 8 bytes from the supplied buffer to create a long.
    static byte[]
    toBytes(UUID uuid)
    Converts the supplied uuid to a byte array.

    Methods inherited from class org.ldaptive.asn1.AbstractDERType

    encode

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • UUID_LENGTH

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

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

    • 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 Details

    • 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 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