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
Nested ClassesModifier and TypeClassDescriptionstatic classPaths to mask, and the value to write as the mask.static interfaceSupplies aMaskingJsonGeneratorDecorator.PathMaskdynamically at runtime.static classValues to mask, and the value to write as the mask.static interfaceSupplies aMaskingJsonGeneratorDecorator.ValueMaskdynamically at runtime. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFieldMasker(FieldMasker fieldMasker) Add the givenFieldMaskerto the maskers used to mask a field.voidAdds the given path to the paths that will be masked.voidAdds the given paths and mask that will be used to determine if a field should be masked.voidaddPathMaskSupplier(MaskingJsonGeneratorDecorator.PathMaskSupplier pathMaskSupplier) Adds the given supplier of paths and mask that will be used to determine if a field should be masked.voidAdds the given comma separated paths to the paths that will be masked.voidAdds the given value regex to the regexes that will be used to determine if a field value should be masked.voidAdds the given value regexes and mask to the regexes that will be used to determine if a field value should be masked.voidaddValueMasker(ValueMasker valueMasker) Add the givenValueMaskerto the maskers used to mask a value.voidaddValueMaskSupplier(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.voidAdds 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.booleanvoidsetDefaultMask(String defaultMask) Sets the default mask value to use for any paths added viaaddPath(String)and values added viaaddValue(String).voidstart()voidstop()
-
Constructor Details
-
MaskingJsonGeneratorDecorator
public MaskingJsonGeneratorDecorator()
-
-
Method Details
-
isStarted
public boolean isStarted() -
start
public void start() -
stop
public void stop() -
decorate
Description copied from interface:JsonGeneratorDecoratorDecorates 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:
decoratein 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 maskvalue will be substituted for values at the given path.- Parameters:
pathToMask- the path to mask. SeePathBasedFieldMaskerfor the format.
-
addPaths
Adds the given comma separated paths to the paths that will be masked.The
default maskvalue will be substituted for values at the given paths.- Parameters:
pathsToMask- comma separate string of paths to mask. SeePathBasedFieldMaskerfor 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 givenFieldMaskerto 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 maskvalue 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 maskvalue 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
maskvalue 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
maskvalue 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 givenValueMaskerto the maskers used to mask a value.- Parameters:
valueMasker- the masker to add
-