- All Implemented Interfaces:
Versioned,Closeable,Flushable,AutoCloseable
JsonGenerator that can mask sensitive field values before delegating to a delegate JsonGenerator.
Identifying field values to mask by path
TheMaskingJsonGenerator 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
TheMaskingJsonGenerator 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:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.fasterxml.jackson.core.JsonGenerator
JsonGenerator.Feature -
Field Summary
FieldsFields inherited from class com.fasterxml.jackson.core.util.JsonGeneratorDelegate
delegate, delegateCopyMethodsFields inherited from class com.fasterxml.jackson.core.JsonGenerator
_cfgPrettyPrinter, DEFAULT_BINARY_WRITE_CAPABILITIES, DEFAULT_TEXTUAL_WRITE_CAPABILITIES, DEFAULT_WRITE_CAPABILITIES -
Constructor Summary
ConstructorsConstructorDescriptionMaskingJsonGenerator(JsonGenerator delegate, Collection<FieldMasker> fieldMaskers, Collection<ValueMasker> valueMaskers) -
Method Summary
Modifier and TypeMethodDescriptionvoidwriteArray(double[] array, int offset, int length) voidwriteArray(int[] array, int offset, int length) voidwriteArray(long[] array, int offset, int length) voidwriteBinary(byte[] data) voidwriteBinary(byte[] data, int offset, int len) voidwriteBinary(Base64Variant b64variant, byte[] data, int offset, int len) intwriteBinary(Base64Variant b64variant, InputStream data, int dataLength) intwriteBinary(InputStream data, int dataLength) voidwriteBoolean(boolean state) voidwriteEmbeddedObject(Object object) voidvoidvoidwriteFieldId(long id) voidvoidwriteFieldName(String name) voidvoidwriteNumber(double v) voidwriteNumber(float v) voidwriteNumber(int v) voidwriteNumber(long v) voidwriteNumber(short v) voidwriteNumber(String encodedValue) voidvoidvoidwriteObjectId(Object id) voidwriteObjectRef(Object id) voidwriteOmittedField(String fieldName) voidwriteRaw(char c) voidwriteRaw(char[] text, int offset, int len) voidvoidvoidvoidwriteRawUTF8String(byte[] text, int offset, int length) voidwriteRawValue(char[] text, int offset, int len) voidwriteRawValue(String text) voidwriteRawValue(String text, int offset, int len) voidvoidwriteStartArray(int size) voidwriteStartArray(Object forValue) voidwriteStartArray(Object forValue, int size) voidvoidwriteStartObject(Object forValue) voidwriteStartObject(Object forValue, int size) voidwriteString(char[] text, int offset, int len) voidvoidwriteString(Reader reader, int len) voidwriteString(String text) voidwriteTypeId(Object id) voidwriteUTF8String(byte[] text, int offset, int length) Methods inherited from class com.fasterxml.jackson.core.util.JsonGeneratorDelegate
assignCurrentValue, canOmitFields, canUseSchema, canWriteBinaryNatively, canWriteFormattedNumbers, canWriteObjectId, canWriteTypeId, close, copyCurrentEvent, copyCurrentStructure, currentValue, delegate, disable, enable, flush, getCharacterEscapes, getCodec, getCurrentValue, getDelegate, getFeatureMask, getHighestEscapedChar, getOutputBuffered, getOutputContext, getOutputTarget, getPrettyPrinter, getSchema, getWriteCapabilities, isClosed, isEnabled, overrideFormatFeatures, overrideStdFeatures, setCharacterEscapes, setCodec, setCurrentValue, setFeatureMask, setHighestNonEscapedChar, setPrettyPrinter, setRootValueSeparator, setSchema, streamWriteConstraints, useDefaultPrettyPrinter, version, writeArray, writeNumber, writeObject, writePOJO, writeTreeMethods inherited from class com.fasterxml.jackson.core.JsonGenerator
_constructWriteException, _constructWriteException, _constructWriteException, _constructWriteException, _copyCurrentContents, _copyCurrentFloatValue, _copyCurrentFloatValueExact, _copyCurrentIntValue, _copyCurrentStringValue, _reportError, _reportUnsupportedOperation, _reportUnsupportedOperation, _throwInternal, _verifyOffsets, _writeSimpleObject, configure, copyCurrentEventExact, getFormatFeatures, isEnabled, writeArrayFieldStart, writeBinaryField, writeBooleanField, writeNullField, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeObjectField, writeObjectFieldStart, writePOJOField, writeRawValue, writeStringField, writeTypePrefix, writeTypeSuffix
-
Field Details
-
MASK
- See Also:
-
-
Constructor Details
-
MaskingJsonGenerator
public MaskingJsonGenerator(JsonGenerator delegate, Collection<FieldMasker> fieldMaskers, Collection<ValueMasker> valueMaskers) - Parameters:
delegate- the generator to which to write potentially masked JSONfieldMaskers-FieldMaskers to mask fieldsvalueMaskers-ValueMaskers to mask values
-
-
Method Details
-
writeArray
- Overrides:
writeArrayin classJsonGeneratorDelegate- Throws:
IOException
-
writeArray
- Overrides:
writeArrayin classJsonGeneratorDelegate- Throws:
IOException
-
writeArray
- Overrides:
writeArrayin classJsonGeneratorDelegate- Throws:
IOException
-
writeFieldName
- Overrides:
writeFieldNamein classJsonGeneratorDelegate- Throws:
IOException
-
writeFieldName
- Overrides:
writeFieldNamein classJsonGeneratorDelegate- Throws:
IOException
-
writeFieldId
- Overrides:
writeFieldIdin classJsonGeneratorDelegate- Throws:
IOException
-
writeBinary
public void writeBinary(Base64Variant b64variant, byte[] data, int offset, int len) throws IOException - Overrides:
writeBinaryin classJsonGeneratorDelegate- Throws:
IOException
-
writeBinary
- Overrides:
writeBinaryin classJsonGenerator- Throws:
IOException
-
writeBinary
- Overrides:
writeBinaryin classJsonGenerator- Throws:
IOException
-
writeBinary
public int writeBinary(Base64Variant b64variant, InputStream data, int dataLength) throws IOException - Overrides:
writeBinaryin classJsonGeneratorDelegate- Throws:
IOException
-
writeBinary
- Overrides:
writeBinaryin classJsonGenerator- Throws:
IOException
-
writeBoolean
- Overrides:
writeBooleanin classJsonGeneratorDelegate- Throws:
IOException
-
writeEmbeddedObject
- Overrides:
writeEmbeddedObjectin classJsonGeneratorDelegate- Throws:
IOException
-
writeNull
- Overrides:
writeNullin classJsonGeneratorDelegate- Throws:
IOException
-
writeNumber
- Overrides:
writeNumberin classJsonGeneratorDelegate- Throws:
IOException
-
writeNumber
- Overrides:
writeNumberin classJsonGeneratorDelegate- Throws:
IOException
-
writeNumber
- Overrides:
writeNumberin classJsonGeneratorDelegate- Throws:
IOException
-
writeNumber
- Overrides:
writeNumberin classJsonGeneratorDelegate- Throws:
IOException
-
writeNumber
- Overrides:
writeNumberin classJsonGeneratorDelegate- Throws:
IOException
-
writeNumber
- Overrides:
writeNumberin classJsonGeneratorDelegate- Throws:
IOException
-
writeNumber
- Overrides:
writeNumberin classJsonGeneratorDelegate- Throws:
IOException
-
writeNumber
- Overrides:
writeNumberin classJsonGeneratorDelegate- Throws:
IOException
-
writeObjectId
- Overrides:
writeObjectIdin classJsonGeneratorDelegate- Throws:
IOException
-
writeObjectRef
- Overrides:
writeObjectRefin classJsonGeneratorDelegate- Throws:
IOException
-
writeOmittedField
- Overrides:
writeOmittedFieldin classJsonGeneratorDelegate- Throws:
IOException
-
writeRaw
- Overrides:
writeRawin classJsonGeneratorDelegate- Throws:
IOException
-
writeRaw
- Overrides:
writeRawin classJsonGeneratorDelegate- Throws:
IOException
-
writeRaw
- Overrides:
writeRawin classJsonGeneratorDelegate- Throws:
IOException
-
writeRaw
- Overrides:
writeRawin classJsonGeneratorDelegate- Throws:
IOException
-
writeRaw
- Overrides:
writeRawin classJsonGeneratorDelegate- Throws:
IOException
-
writeRawValue
- Overrides:
writeRawValuein classJsonGeneratorDelegate- Throws:
IOException
-
writeRawValue
- Overrides:
writeRawValuein classJsonGeneratorDelegate- Throws:
IOException
-
writeRawValue
- Overrides:
writeRawValuein classJsonGeneratorDelegate- Throws:
IOException
-
writeRawUTF8String
- Overrides:
writeRawUTF8Stringin classJsonGeneratorDelegate- Throws:
IOException
-
writeStartArray
- Overrides:
writeStartArrayin classJsonGeneratorDelegate- Throws:
IOException
-
writeStartArray
- Overrides:
writeStartArrayin classJsonGeneratorDelegate- Throws:
IOException
-
writeStartArray
- Overrides:
writeStartArrayin classJsonGeneratorDelegate- Throws:
IOException
-
writeStartArray
- Overrides:
writeStartArrayin classJsonGeneratorDelegate- Throws:
IOException
-
writeStartObject
- Overrides:
writeStartObjectin classJsonGeneratorDelegate- Throws:
IOException
-
writeStartObject
- Overrides:
writeStartObjectin classJsonGeneratorDelegate- Throws:
IOException
-
writeStartObject
- Overrides:
writeStartObjectin classJsonGeneratorDelegate- Throws:
IOException
-
writeString
- Overrides:
writeStringin classJsonGeneratorDelegate- Throws:
IOException
-
writeString
- Overrides:
writeStringin classJsonGeneratorDelegate- Throws:
IOException
-
writeString
- Overrides:
writeStringin classJsonGeneratorDelegate- Throws:
IOException
-
writeString
- Overrides:
writeStringin classJsonGeneratorDelegate- Throws:
IOException
-
writeUTF8String
- Overrides:
writeUTF8Stringin classJsonGeneratorDelegate- Throws:
IOException
-
writeTypeId
- Overrides:
writeTypeIdin classJsonGeneratorDelegate- Throws:
IOException
-
writeEndArray
- Overrides:
writeEndArrayin classJsonGeneratorDelegate- Throws:
IOException
-
writeEndObject
- Overrides:
writeEndObjectin classJsonGeneratorDelegate- Throws:
IOException
-