Package org.ldaptive.asn1
Class UuidType
- java.lang.Object
-
- org.ldaptive.asn1.AbstractDERType
-
- org.ldaptive.asn1.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 byte[]
derItem
UUID to encode.private static int
UUID_LENGTH
Number of bytes in a uuid.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods 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()
Encode this object into its DER type.protected static long
readLong(DERBuffer buffer)
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
-
-
-
-
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 typeitem
- 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 interfaceDEREncoder
- 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
-
-