Class FieldNameBasedFieldMasker

java.lang.Object
net.logstash.logback.mask.FieldNameBasedFieldMasker
All Implemented Interfaces:
FieldMasker

public class FieldNameBasedFieldMasker extends Object implements FieldMasker
Masks values of specific JSON field names within a JSON stream.
  • Constructor Details

    • FieldNameBasedFieldMasker

      public FieldNameBasedFieldMasker(Set<String> fieldNamesToMask, Object mask)
      Parameters:
      fieldNamesToMask - the names of fields in the JSON stream to mask
      mask - the value to write for fields in the fieldNamesToMask
  • Method Details

    • mask

      public Object mask(JsonStreamContext context)
      Description copied from interface: FieldMasker
      If the field at the JSON stream context's current path should be masked, then returns the masked value to write as the field's value. The MaskingJsonGenerator will write the returned masked value as the field's value (instead of the original field's value).

      If the JSON stream context's current path should NOT be masked, returns null.

      Specified by:
      mask in interface FieldMasker
      Parameters:
      context - the current JSON stream context, which can be used to determine the path within the JSON output.
      Returns:
      A non-null masked value to write if the current field should be masked. Otherwise null if the current field should not be masked. To write a JSON null value as the masked value, return NullNode.instance. To write "****", the return MaskingJsonGenerator.MASK