Package net.logstash.logback.mask
Class MaskingJsonGeneratorDecorator
java.lang.Object
net.logstash.logback.mask.MaskingJsonGeneratorDecorator
- All Implemented Interfaces:
LifeCycle
,JsonGeneratorDecorator
public class MaskingJsonGeneratorDecorator
extends Object
implements JsonGeneratorDecorator, LifeCycle
A
JsonGeneratorDecorator
that wraps a JsonGenerator
with a MaskingJsonGenerator
,
so that sensitive field values can be masked.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Paths to mask, and the value to write as the mask.static interface
Supplies aMaskingJsonGeneratorDecorator.PathMask
dynamically at runtime.static class
Values to mask, and the value to write as the mask.static interface
Supplies aMaskingJsonGeneratorDecorator.ValueMask
dynamically at runtime. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addFieldMasker
(FieldMasker fieldMasker) Add the givenFieldMasker
to the maskers used to mask a field.void
Adds the given path to the paths that will be masked.void
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
Adds the given comma separated paths to the paths that will be masked.void
Adds the given value regex to the regexes that will be used to determine if a field value should be masked.void
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 givenValueMasker
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
Adds the comma separated string of value regexes to the regexes that will be used to determine if a field value should be masked.decorate
(JsonGenerator generator) Decorates the given generator, and returns the decorated generator.boolean
void
setDefaultMask
(String defaultMask) Sets the default mask value to use for any paths added viaaddPath(String)
and values added viaaddValue(String)
.void
start()
void
stop()
-
Constructor Details
-
MaskingJsonGeneratorDecorator
public MaskingJsonGeneratorDecorator()
-
-
Method Details
-
isStarted
public boolean isStarted() -
start
public void start() -
stop
public void stop() -
decorate
Description copied from interface:JsonGeneratorDecorator
Decorates the given generator, and returns the decorated generator.The returned decorator does not need to be the same object as the given generator.
- Specified by:
decorate
in interfaceJsonGeneratorDecorator
- Parameters:
generator
- the generator to decorate- Returns:
- the decorated generator
-
setDefaultMask
Sets the default mask value to use for any paths added viaaddPath(String)
and values added viaaddValue(String)
.By default, this is "****".
- Parameters:
defaultMask
- the default mask value to be used to mask real values.
-
addPath
Adds the given path to the paths that will be masked.The
default mask
value will be substituted for values at the given path.- Parameters:
pathToMask
- the path to mask. SeePathBasedFieldMasker
for the format.
-
addPaths
Adds the given comma separated paths to the paths that will be masked.The
default mask
value will be substituted for values at the given paths.- Parameters:
pathsToMask
- comma separate string of paths to mask. SeePathBasedFieldMasker
for the format.
-
addPathMask
Adds the given paths and mask that will be used to determine if a field should be masked.- Parameters:
pathMask
- a paths used to determine if a value should be masked, and their corresponding mask value.
-
addPathMaskSupplier
Adds the given supplier of paths and mask that will be used to determine if a field should be masked.- Parameters:
pathMaskSupplier
- a supplier of paths used to determine if a value should be masked, and their corresponding mask value.
-
addFieldMasker
Add the givenFieldMasker
to the maskers used to mask a field.- Parameters:
fieldMasker
- the masker to add
-
addValue
Adds the given value regex to the regexes that will be used to determine if a field value should be masked.The
default mask
value will be substituted for values that match the given regex.- Parameters:
valueToMask
- a regular expression used to determine if a value should be masked.
-
addValues
Adds the comma separated string of value regexes to the regexes that will be used to determine if a field value should be masked.The
default mask
value will be substituted for values that match the given regexes.- Parameters:
valuesToMask
- comma-separated string of regular expressions used to determine if a value should be masked.
-
addValueMask
Adds the given value regexes and mask to the regexes that will be used to determine if a field value should be masked.The
mask
value will be written for values that match any of thevalue regexes
.- Parameters:
valueMask
- regular expressions used to determine if a value should be masked, and their corresponding mask value
-
addValueMaskSupplier
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.The
mask
value will be written for values that match any of thevalue regexes
.- Parameters:
valueMaskSupplier
- a supplier of regular expressions used to determine if a value should be masked, and their corresponding mask value
-
addValueMasker
Add the givenValueMasker
to the maskers used to mask a value.- Parameters:
valueMasker
- the masker to add
-