Class FormXmlCrypto


  • public class FormXmlCrypto
    extends Object
    Provides form XML data encryption and decryption functions.
    Since:
    5.0
    • Constructor Detail

      • FormXmlCrypto

        public FormXmlCrypto()
    • Method Detail

      • encrypt

        public static String encrypt​(byte[] xmlData,
                                     String requestKey)
        Convert form xml data to a compressed encrypted string based on AES-CBC 128 bit. pipeline: original form data (byte[]) -> compressed data (byte[] using zlib) -> AES encrypted data (using generated AES key and last 16 bytes of request key to be IV) -> combined data: (byte[]) request key (32 bytes) + AES key (16 bytes) + AES encrypted Data -> Base64 String of combined data
        Parameters:
        xmlData - the byte array of form data (required)
        requestKey - the TM request key (required)
        Returns:
        a String with the compressed encrypted data in base64 format
      • decrypt

        public static String decrypt​(String formBase64Data)
                              throws FormXmlCrypto.CryptoException
        Decrypt and uncompress form xml data from client pipeline: client submission data base64 string -> get byte array data from Base64 string -> slice to Request key (32 bytes) + AES key (16 bytes) + encrypted Data (AES) -> decrypt data (byte[]) using AES key and last 16 bytes of request key being IV -> uncompress data using zlib (String)
        Parameters:
        formBase64Data - the encrypted compressed data from client in base64 format (required)
        Returns:
        a String of original form XML data
        Throws:
        FormXmlCrypto.CryptoException - if the form data could not be decrypted
      • getRequestKeyFromClientEncryptedCompressedData

        public static String getRequestKeyFromClientEncryptedCompressedData​(String formBase64Data)
        Return the TM RequestKey for the given base64 encoded form XML data.
        Parameters:
        formBase64Data - the form XML base 64 encoded data (requried)
        Returns:
        the TM RequestKey for the given base64 encoded form XML data