Class MaskStrings

  • All Implemented Interfaces:
    ColumnMapper

    public class MaskStrings
    extends Object
    implements ColumnMapper
    A ColumnMapper implementation that ensures that string values are masked. Based on the constructor different masking methods could be used.
    Author:
    Randall Hauch, Jan-Hendrik Dolling
    • Constructor Detail

      • MaskStrings

        public MaskStrings​(String maskValue)
        Create a ColumnMapper that masks string values with a predefined value.
        Parameters:
        maskValue - the value that should be used in place of the actual value; may not be null
        Throws:
        IllegalArgumentException - if the {@param maskValue} is null
      • MaskStrings

        public MaskStrings​(byte[] salt,
                           String hashAlgorithm,
                           MaskStrings.HashingByteArrayStrategy hashingByteArrayStrategy)
        Create a ColumnMapper that masks string values by hashing the input value. The hash is automatically shortened to the length of the column.
        Parameters:
        salt - the salt that is used within the hash function
        hashAlgorithm - the hash function that is used to mask the columns string values written in source records; must be on of Java Cryptography Architecture Standard Algorithm MessageDigest.
        Throws:
        IllegalArgumentException - if the {@param salt} or {@param hashAlgorithm} are null
    • Method Detail

      • create

        public ValueConverter create​(Column column)
        Description copied from interface: ColumnMapper
        Create for the given column a function that maps values.
        Specified by:
        create in interface ColumnMapper
        Parameters:
        column - the column description; never null
        Returns:
        the function that converts the value; may be null
      • alterFieldSchema

        public void alterFieldSchema​(Column column,
                                     org.apache.kafka.connect.data.SchemaBuilder schemaBuilder)
        Description copied from interface: ColumnMapper
        Optionally annotate the schema with properties to better capture the mapping behavior.
        Specified by:
        alterFieldSchema in interface ColumnMapper
        Parameters:
        column - the column definition; never null
        schemaBuilder - the builder for the Field's schema; never null