Class SubmissionEncryptionService

java.lang.Object
formflow.library.data.SubmissionEncryptionService

@Service public class SubmissionEncryptionService extends Object
Service providing encryption and decryption of designated fields in a Submission using Google's Tink Cryptographic Library
  • Field Details

    • ENCRYPT_SUFFIX

      public final String ENCRYPT_SUFFIX
      Suffix added to the field name for encrypted fields
      See Also:
  • Constructor Details

    • SubmissionEncryptionService

      public SubmissionEncryptionService(@Value("${form-flow.encryption-key:#{null}}") String key, @Value("${form-flow.inputs: \'formflow.library.inputs.\'}") String inputConfigPath)
      Constructs an instance of the SubmissionEncryptionService
      Parameters:
      key - the key used to encrypt the fields
      inputConfigPath - the package path where inputs classes are located
  • Method Details

    • encrypt

      public Submission encrypt(Submission submission)
      Go through "@Encrypt" annotations and replace fields with encrypted value.

      Ex.
      Given: {secret: "this is a secret"}
      Result: {secret_encrypted: "some-encrypted-chars"}

      Parameters:
      submission - submission to be encrypted
      Returns:
      encrypted copy of the given submission
    • decrypt

      public Submission decrypt(Submission submission)
      Goes through "@Encrypted" annotations and replaces the encrypted fields with the decrypted value.

      Ex.
      Given: {secret_encrypted: "some-encrypted-chars"}
      Result: {secret: "this is a secret"}

      Parameters:
      submission - submission to be decrypted
      Returns:
      decrypted copy of the given submission