Class ExampleUserDefinedFuncHandler
- java.lang.Object
-
- com.amazonaws.athena.connector.lambda.handlers.UserDefinedFunctionHandler
-
- com.amazonaws.athena.connectors.example.ExampleUserDefinedFuncHandler
-
- All Implemented Interfaces:
com.amazonaws.services.lambda.runtime.RequestStreamHandler
public class ExampleUserDefinedFuncHandler extends UserDefinedFunctionHandler
-
-
Field Summary
Fields Modifier and Type Field Description static int
GCM_IV_LENGTH
static int
GCM_TAG_LENGTH
-
Constructor Summary
Constructors Constructor Description ExampleUserDefinedFuncHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
decrypt(String payload)
Decrypts the provided value using our application's secret key and encryption Algo.Integer
extract_tx_id(Map<String,Object> transaction)
This UDF extracts an 'Account' from the input STRUCT (provided as a Map).protected String
getEncryptionKey()
DO _NOT_ manage keys like this in real world usage.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.-
Methods inherited from class com.amazonaws.athena.connector.lambda.handlers.UserDefinedFunctionHandler
doHandleRequest, handleRequest, onPing, processRows
-
-
-
-
Field Detail
-
GCM_IV_LENGTH
public static final int GCM_IV_LENGTH
- See Also:
- Constant Field Values
-
GCM_TAG_LENGTH
public static final int GCM_TAG_LENGTH
- See Also:
- Constant Field Values
-
-
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.
-
-