public class MaskingJsonGeneratorDecorator extends Object implements JsonGeneratorDecorator, LifeCycle
JsonGeneratorDecorator
that wraps a JsonGenerator
with a MaskingJsonGenerator
,
so that sensitive field values can be masked.Modifier and Type | Class and Description |
---|---|
static class |
MaskingJsonGeneratorDecorator.PathMask
Paths to mask, and the value to write as the mask.
|
static interface |
MaskingJsonGeneratorDecorator.PathMaskSupplier
Supplies a
MaskingJsonGeneratorDecorator.PathMask dynamically at runtime. |
static class |
MaskingJsonGeneratorDecorator.ValueMask
Values to mask, and the value to write as the mask.
|
static interface |
MaskingJsonGeneratorDecorator.ValueMaskSupplier
Supplies a
MaskingJsonGeneratorDecorator.ValueMask dynamically at runtime. |
Constructor and Description |
---|
MaskingJsonGeneratorDecorator() |
Modifier and Type | Method and Description |
---|---|
void |
addFieldMasker(FieldMasker fieldMasker)
Add the given
FieldMasker to the maskers used to mask a field. |
void |
addPath(String pathToMask)
Adds the given path to the paths that will be masked.
|
void |
addPathMask(MaskingJsonGeneratorDecorator.PathMask pathMask)
Adds the given paths and mask that will be used to determine if a field should be masked.
|
void |
addPathMaskSupplier(MaskingJsonGeneratorDecorator.PathMaskSupplier pathMaskSupplier)
Adds the given supplier of paths and mask that will be used to determine if a field should be masked.
|
void |
addPaths(String pathsToMask)
Adds the given comma separated paths to the paths that will be masked.
|
void |
addValue(String valueToMask)
Adds the given value regex to the regexes that will be used to determine if a field value should be masked.
|
void |
addValueMask(MaskingJsonGeneratorDecorator.ValueMask valueMask)
Adds the given value regexes and mask to the regexes that will be used to determine if a field value should be masked.
|
void |
addValueMasker(ValueMasker valueMasker)
Add the given
ValueMasker to the maskers used to mask a value. |
void |
addValueMaskSupplier(MaskingJsonGeneratorDecorator.ValueMaskSupplier valueMaskSupplier)
Adds the given supplier of value regexes and mask to the regexes that will be used to determine if a field value should be masked.
|
void |
addValues(String valuesToMask)
Adds the comma separated string of value regexes to the regexes that will be used to determine if a field value should be masked.
|
JsonGenerator |
decorate(JsonGenerator generator)
Decorates the given generator, and returns the decorated generator.
|
boolean |
isStarted() |
void |
setDefaultMask(String defaultMask)
Sets the default mask value to use for any paths added via
addPath(String)
and values added via addValue(String) . |
void |
start() |
void |
stop() |
public JsonGenerator decorate(JsonGenerator generator)
JsonGeneratorDecorator
The returned decorator does not need to be the same object as the given generator.
decorate
in interface JsonGeneratorDecorator
generator
- the generator to decoratepublic void setDefaultMask(String defaultMask)
addPath(String)
and values added via addValue(String)
.
By default, this is .
defaultMask
- the default mask value to be used to mask real values.public void addPath(String pathToMask)
The default mask
value will be substituted for values at the given path.
pathToMask
- the path to mask. See PathBasedFieldMasker
for the format.public void addPaths(String pathsToMask)
The default mask
value will be substituted for values at the given paths.
pathsToMask
- comma separate string of paths to mask. See PathBasedFieldMasker
for the format.public void addPathMask(MaskingJsonGeneratorDecorator.PathMask pathMask)
pathMask
- a paths used to determine if a value should be masked, and their corresponding mask value.public void addPathMaskSupplier(MaskingJsonGeneratorDecorator.PathMaskSupplier pathMaskSupplier)
pathMaskSupplier
- a supplier of paths used to determine if a value should be masked, and their corresponding mask value.public void addFieldMasker(FieldMasker fieldMasker)
FieldMasker
to the maskers used to mask a field.fieldMasker
- the masker to addpublic void addValue(String valueToMask)
The default mask
value will be substituted for values that match the given regex.
valueToMask
- a regular expression used to determine if a value should be masked.public void addValues(String valuesToMask)
The default mask
value will be substituted for values that match the given regexes.
valuesToMask
- comma-separated string of regular expressions used to determine if a value should be masked.public void addValueMask(MaskingJsonGeneratorDecorator.ValueMask valueMask)
The mask
value will be written for values that match any of the value regexes
.
valueMask
- regular expressions used to determine if a value should be masked, and their corresponding mask valuepublic void addValueMaskSupplier(MaskingJsonGeneratorDecorator.ValueMaskSupplier valueMaskSupplier)
The mask
value will be written for values that match any of the value regexes
.
valueMaskSupplier
- a supplier of regular expressions used to determine if a value should be masked, and their corresponding mask valuepublic void addValueMasker(ValueMasker valueMasker)
ValueMasker
to the maskers used to mask a value.valueMasker
- the masker to addCopyright © 2013–2022. All rights reserved.