Class ExampleUserDefinedFuncHandler

  • All Implemented Interfaces:
    com.amazonaws.services.lambda.runtime.RequestStreamHandler

    public class ExampleUserDefinedFuncHandler
    extends UserDefinedFunctionHandler
    • Constructor Detail

      • ExampleUserDefinedFuncHandler

        public ExampleUserDefinedFuncHandler()
    • Method Detail

      • extract_tx_id

        public Integer extract_tx_id​(Map<String,​Object> transaction)
        This UDF extracts an 'Account' from the input STRUCT (provided as a Map). In this case 'Account' is an application specific concept and very custom to our test dataset's schema.
        Parameters:
        transaction - The transaction from which to extract the id field.
        Returns:
        An Integer containing the Transaction ID or -1 if the id couldn't be extracted.
      • decrypt

        public String decrypt​(String payload)
        Decrypts the provided value using our application's secret key and encryption Algo.
        Parameters:
        payload - The cipher text to decrypt.
        Returns:
        ClearText version if the input payload, null if the decrypt failed.
      • symmetricDecrypt

        public String symmetricDecrypt​(String ciphertext,
                                       String secretKey)
        This usage of AES-GCM and is only meant to illustrate how one could use a UDF for masking a field using encryption. In production scenarios we would recommend using AWS KMS for Key Management and a strong cipher like AES-GCM.
        Parameters:
        ciphertext - The text to decrypt.
        secretKey - The password/key to use to decrypt the text.
        Returns:
        The decrypted text.
      • getEncryptionKey

        protected String getEncryptionKey()
        DO _NOT_ manage keys like this in real world usage. We are hard coding a key here to work with the tutorial's generated data set. In production scenarios we would recommend using AWS KMS for Key Management and a strong cipher like AES-GCM.
        Returns:
        A String representation of the AES encryption key to use to decrypt data.