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

  • Constructor Details

    • TokenBlobUtils

      public TokenBlobUtils()
  • Method Details

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