Package org.ldaptive.asn1
Class IntegerType
java.lang.Object
org.ldaptive.asn1.AbstractDERType
org.ldaptive.asn1.IntegerType
- All Implemented Interfaces:
DEREncoder
Converts arbitrary-precision integers to and from their DER encoded format.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionIntegerType(int item) Creates a new integer type.IntegerType(BigInteger item) Creates a new integer type.IntegerType(DERTag tag, int item) Creates a new integer type.IntegerType(DERTag tag, BigInteger item) Creates a new integer type. -
Method Summary
Modifier and TypeMethodDescriptionstatic BigIntegerConverts bytes in the buffer to an integer by reading from the current position to the limit, which assumes the bytes of the integer are in big-endian order.static BigIntegerdecodeUnsigned(DERBuffer encoded) Converts bytes in the buffer to an unsigned integer by reading from the current position to the limit, which assumes the bytes of the integer are in big-endian order.static intdecodeUnsignedPrimitive(DERBuffer encoded) Converts bytes in the buffer to an unsigned primitive integer by reading from the current position to the limit, which assumes the bytes of the integer are in big-endian order.byte[]encode()Encode this object into its DER type.static byte[]Converts the supplied big integer to a byte array.Methods inherited from class org.ldaptive.asn1.AbstractDERType
encode
-
Field Details
-
derItem
private final byte[] derItemInteger to encode.
-
-
Constructor Details
-
IntegerType
Creates a new integer type.- Parameters:
item- to DER encode
-
IntegerType
public IntegerType(int item) Creates a new integer type.- Parameters:
item- to DER encode
-
IntegerType
Creates a new integer type.- Parameters:
tag- der tag associated with this typeitem- to DER encode- Throws:
IllegalArgumentException- if the der tag is constructed
-
IntegerType
Creates a new integer type.- Parameters:
tag- der tag associated with this typeitem- to DER encode- Throws:
IllegalArgumentException- if the der tag is constructed
-
-
Method Details
-
encode
public byte[] encode()Description copied from interface:DEREncoderEncode this object into its DER type.- Specified by:
encodein interfaceDEREncoder- Returns:
- DER encoded object
-
decode
Converts bytes in the buffer to an integer by reading from the current position to the limit, which assumes the bytes of the integer are in big-endian order.- Parameters:
encoded- buffer containing DER-encoded data where the buffer is positioned at the start of integer bytes and the limit is set beyond the last byte of integer data.- Returns:
- decoded bytes as an integer of arbitrary size.
-
decodeUnsigned
Converts bytes in the buffer to an unsigned integer by reading from the current position to the limit, which assumes the bytes of the integer are in big-endian order.- Parameters:
encoded- buffer containing DER-encoded data where the buffer is positioned at the start of integer bytes and the limit is set beyond the last byte of integer data.- Returns:
- decoded bytes as an unsigned integer of arbitrary size.
-
decodeUnsignedPrimitive
Converts bytes in the buffer to an unsigned primitive integer by reading from the current position to the limit, which assumes the bytes of the integer are in big-endian order. This method reads up to 4 bytes from the buffer.- Parameters:
encoded- buffer containing DER-encoded data where the buffer is positioned at the start of integer bytes and the limit is set beyond the last byte of integer data.- Returns:
- decoded bytes as an unsigned integer.
- Throws:
IllegalArgumentException- if the buffer contains more than 4 bytes
-
toBytes
Converts the supplied big integer to a byte array.- Parameters:
i- to convert- Returns:
- byte array
-