Class PropertyMaskingSafePropertyWriter
- All Implemented Interfaces:
com.fasterxml.jackson.databind.BeanProperty,com.fasterxml.jackson.databind.util.Named,Serializable
This writer also allows masking (hiding the true value) of certain fields based on their name by writing out asterisks instead of the true value.
NOTE: Generally masking should be used only on String fields, because otherwise the type in the resulting JSON will
be different from the source type. For example, if a class has a "secretNumber" of type "int" and it is masked, the
resulting JSON contains a String instead of an int, which will likely cause problems if a downstream system reads
the JSON expecting an int. For such cases, consider using JsonView instead.
Note that jackson-core and jackson-databind must be available at runtime.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.fasterxml.jackson.databind.BeanProperty
com.fasterxml.jackson.databind.BeanProperty.Bogus, com.fasterxml.jackson.databind.BeanProperty.Std -
Field Summary
Fields inherited from class com.fasterxml.jackson.databind.ser.BeanPropertyWriter
_accessorMethod, _cfgSerializationType, _contextAnnotations, _declaredType, _dynamicSerializers, _field, _includeInViews, _internalSettings, _member, _name, _nonTrivialBaseType, _nullSerializer, _serializer, _suppressableValue, _suppressNulls, _typeSerializer, _wrapperName, MARKER_FOR_EMPTYFields inherited from class com.fasterxml.jackson.databind.introspect.ConcreteBeanPropertyBase
_aliases, _metadataFields inherited from interface com.fasterxml.jackson.databind.BeanProperty
EMPTY_FORMAT, EMPTY_INCLUDE -
Constructor Summary
ConstructorsConstructorDescriptionPropertyMaskingSafePropertyWriter(com.fasterxml.jackson.databind.ser.BeanPropertyWriter base, List<String> maskedFieldRegexps) Construct new instance wrapping the givenBeanPropertyWriterusing the given list of (String) regular expressions that define the properties which should be masked.PropertyMaskingSafePropertyWriter(com.fasterxml.jackson.databind.ser.BeanPropertyWriter base, PropertyMaskingOptions options) Construct new instance wrapping the givenBeanPropertyWriterusing the givenPropertyMaskingOptionsto define properties to be masked, as well as replacement text for masked fields and serialization errors. -
Method Summary
Modifier and TypeMethodDescriptionvoidserializeAsField(Object bean, com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider prov) Methods inherited from class com.fasterxml.jackson.databind.ser.BeanPropertyWriter
_depositSchemaProperty, _findAndAddDynamic, _handleSelfReference, _new, assignNullSerializer, assignSerializer, assignTypeSerializer, depositSchemaProperty, depositSchemaProperty, fixAccess, get, getAnnotation, getContextAnnotation, getFullName, getGenericPropertyType, getInternalSetting, getMember, getName, getPropertyType, getRawSerializationType, getSerializationType, getSerializedName, getSerializer, getType, getTypeSerializer, getViews, getWrapperName, hasNullSerializer, hasSerializer, isUnwrapping, removeInternalSetting, rename, serializeAsElement, serializeAsOmittedField, serializeAsPlaceholder, setInternalSetting, setNonTrivialBaseType, toString, unwrappingWriter, willSuppressNulls, wouldConflictWithNameMethods inherited from class com.fasterxml.jackson.databind.ser.PropertyWriter
findAnnotationMethods inherited from class com.fasterxml.jackson.databind.introspect.ConcreteBeanPropertyBase
findAliases, findFormatOverrides, findPropertyFormat, findPropertyInclusion, getMetadata, isRequired, isVirtual
-
Constructor Details
-
PropertyMaskingSafePropertyWriter
public PropertyMaskingSafePropertyWriter(com.fasterxml.jackson.databind.ser.BeanPropertyWriter base, List<String> maskedFieldRegexps) Construct new instance wrapping the givenBeanPropertyWriterusing the given list of (String) regular expressions that define the properties which should be masked.Default values for masked fields and serialization errors are used. The default values are defined by
PropertyMaskingOptions.- Parameters:
base- the base or delegateBeanPropertyWriterto usemaskedFieldRegexps- list containing regular expressions that define the properties to mask
-
PropertyMaskingSafePropertyWriter
public PropertyMaskingSafePropertyWriter(com.fasterxml.jackson.databind.ser.BeanPropertyWriter base, PropertyMaskingOptions options) Construct new instance wrapping the givenBeanPropertyWriterusing the givenPropertyMaskingOptionsto define properties to be masked, as well as replacement text for masked fields and serialization errors.- Parameters:
base- the base or delegateBeanPropertyWriterto useoptions- the options to use- See Also:
-
-
Method Details
-
serializeAsField
public void serializeAsField(Object bean, com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider prov) - Overrides:
serializeAsFieldin classcom.fasterxml.jackson.databind.ser.BeanPropertyWriter
-