Class AsymmetricEncryptingReader


public class AsymmetricEncryptingReader extends EncryptingReader
An EncryptingReader that encrypts fields with a symmetric key and appends that key, encrypted with a public key, to every value after a -; read the values back with an AsymmetricDecryptingReader.
  • Field Details

    • MINIMUM_SYMMETRIC_LENGTH

      public static final int MINIMUM_SYMMETRIC_LENGTH
      See Also:
  • Constructor Details

    • AsymmetricEncryptingReader

      public AsymmetricEncryptingReader(DataReader nestedDataReader)
    • AsymmetricEncryptingReader

      public AsymmetricEncryptingReader(DataReader nestedDataReader, String asymmetricAlgorithm, PublicKey asymmetricKey)
  • Method Details

    • getAsymmetricAlgorithm

      public String getAsymmetricAlgorithm()
      Returns the algorithm used with the public key to encrypt the symmetric key, such as RSA; required to open the reader.
    • setAsymmetricAlgorithm

      public AsymmetricEncryptingReader setAsymmetricAlgorithm(String asymmetricAlgorithm)
      Sets the algorithm used with the public key to encrypt the symmetric key, such as RSA; required to open the reader.
    • getAsymmetricKey

      public PublicKey getAsymmetricKey()
      Returns the public key used to encrypt the symmetric key; required to open the reader.
    • setAsymmetricKey

      public AsymmetricEncryptingReader setAsymmetricKey(PublicKey asymmetricKey)
      Sets the public key used to encrypt the symmetric key; required to open the reader.
    • getSymmetricAlgorithm

      public String getSymmetricAlgorithm()
      Returns the algorithm of the symmetric key that encrypts the fields (default is AES).
    • setSymmetricAlgorithm

      public AsymmetricEncryptingReader setSymmetricAlgorithm(String symmetricAlgorithm)
      Sets the algorithm of the symmetric key that encrypts the fields (default is AES).
    • getSymmetricKeyBitLength

      public int getSymmetricKeyBitLength()
      Returns the size in bits of the symmetric key generated when none is set (default is 128); it must be at least MINIMUM_SYMMETRIC_LENGTH.
    • setSymmetricKeyBitLength

      public AsymmetricEncryptingReader setSymmetricKeyBitLength(int symmetricKeyBitLength)
      Sets the size in bits of the symmetric key generated when none is set (default is 128); it must be at least MINIMUM_SYMMETRIC_LENGTH.
    • getSymmetricKey

      public SecretKey getSymmetricKey()
      Returns the symmetric key that encrypts the fields; if none is set, one is generated when the reader opens.
    • setSymmetricKey

      public AsymmetricEncryptingReader setSymmetricKey(SecretKey symmetricKey)
      Sets the symmetric key that encrypts the fields; if none is set, one is generated when the reader opens.
    • addFields

      public AsymmetricEncryptingReader addFields(Collection<String> fieldNames)
      Description copied from class: EncryptingReader
      Adds fields to encrypt; only allowed before the reader is opened.
      Overrides:
      addFields in class EncryptingReader
    • addFields

      public AsymmetricEncryptingReader addFields(String... fieldNames)
      Description copied from class: EncryptingReader
      Adds fields to encrypt; only allowed before the reader is opened.
      Overrides:
      addFields in class EncryptingReader
    • initCipher

      protected void initCipher()
      Description copied from class: EncryptingReader
      Initializes or resets EncryptingReader.cipher for encryption; called when the reader opens and again after a field fails to encrypt.
      Specified by:
      initCipher in class EncryptingReader
    • encryptFieldImpl

      protected void encryptFieldImpl(Field field) throws Throwable
      Description copied from class: EncryptingReader
      Replaces the field's value in place with its encrypted form.
      Specified by:
      encryptFieldImpl in class EncryptingReader
      Throws:
      Throwable
    • addExceptionProperties

      public DataException addExceptionProperties(DataException exception)
      Description copied from class: Endpoint
      Adds this endpoint's current state to a DataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.
      Overrides:
      addExceptionProperties in class EncryptingReader