Package org.forgerock.am.cts.utils.blob
Class TokenBlobUtils
- java.lang.Object
-
- org.forgerock.am.cts.utils.blob.TokenBlobUtils
-
public class TokenBlobUtils extends Object
Responsible for handling the encoding and decoding of the binary object format the CTS Token.- See Also:
Token.getBlob()
-
-
Constructor Summary
Constructors Constructor Description TokenBlobUtils()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
fromUTF8(String contents)
Convert the String contents into an encoded binary representation.String
getBlobAsString(Token token)
Retrieve the blob data of the Token in String format.void
setBlobFromString(Token token, String blob)
Assign the given String to the Token by converting it to a byte[] first.String
toUTF8(byte[] data)
Convert a byte array into a String using the UTF-8 encoding.
-
-
-
Field Detail
-
ENCODING
public static final String ENCODING
- See Also:
- Constant Field Values
-
-
Method Detail
-
getBlobAsString
public String getBlobAsString(Token token)
Retrieve the blob data of the Token in String format.- Parameters:
token
- Non null.- Returns:
- maybe null if the Token has not binary data assigned.
- Throws:
IllegalStateException
- If there was a problem decoding the string.
-
setBlobFromString
public void setBlobFromString(Token token, String blob)
Assign the given String to the Token by converting it to a byte[] first.- Parameters:
token
- Non null Token.blob
- Non null String data to convert to binary and store in Token.- Throws:
IllegalStateException
- If there was a problem encoding the String.
-
toUTF8
public String toUTF8(byte[] data) throws UnsupportedEncodingException
Convert a byte array into a String using the UTF-8 encoding.- Parameters:
data
- Non null byte[] to be converted.- Returns:
- A non null but possibly empty.
- Throws:
UnsupportedEncodingException
- indicates there was a problem decoding the data.
-
fromUTF8
public byte[] fromUTF8(String contents) throws UnsupportedEncodingException
Convert the String contents into an encoded binary representation.- Parameters:
contents
- Non null contents to convert.- Returns:
- Non null response.
- Throws:
UnsupportedEncodingException
- If there was an error performing the conversion.
-
-