Class MaskingJsonGenerator

All Implemented Interfaces:
Versioned, Closeable, Flushable, AutoCloseable

public class MaskingJsonGenerator extends JsonGeneratorDelegate
A JsonGenerator that can mask sensitive field values before delegating to a delegate JsonGenerator.

Identifying field values to mask by path

The MaskingJsonGenerator uses a collection of FieldMaskers to identify fields to mask by JSON path.

These field maskers are invoked after a new field name is written to determine if the field's value should be masked. If any masker returns a non-null value, then the returned value will be written as the field's value (instead of the original field value). Note that the masked value's type might differ from the fields original type.

Example FieldMaskers:

Identifying field values to mask by value

The MaskingJsonGenerator uses a collection of ValueMaskers to mask field values by JSON path and field value.

These value maskers are invoked each time a new number or string scalar value is written to determine if the value should be masked. If all maskers return null, then the value is written as-is (i.e. not masked). If any masker returns non-null, then the returned value will be written as the field value.

Raw values are NOT masked.

It is much more efficient to mask field values by path, rather than by field value. Therefore, prefer using FieldMaskers instead of ValueMaskers whenever possible.

Example value maskers: