Provides functionality for obfuscating text. This can be useful for logging information that contains sensitive information.
Besides providing a framework that can be extended to provide simple or complex obfuscators, this library comes with a small set of predefined obfuscators. Most can be found through factory methods on class Obfuscator. See Examples for more information.
An Obfuscator
has method streamTo
which takes a StringBuilder
, Writer
or other Appendable
, and returns a Writer
that will obfuscate the written text automatically.
The following methods of Obfuscator
can be used to help prevent accidentally leaking string representations of objects, for instance by logging them:
obfuscateList
,obfuscateSet
andobfuscateCollection
createList
,Set
andCollection
decorators respectively that obfuscate separate elements when callingtoString()
.obfuscateMap
creates aMap
decorator that obfuscates separate values (but not keys) when callingtoString()
.obfuscateObject
creates a wrapper around an existing object that obfuscates the object when callingtoString()
.
Besides obfuscating simple text, it's possible to obfuscate complex structures using the following classes and libraries:
- MapObfuscator can obfuscate maps by providing a separate
Obfuscator
for each entry. Entries can even have no obfuscation at all. - PropertiesObfuscator can obfuscate
Properties
objects by providing a separateObfuscator
for each property. Properties can even have no obfuscation at all. - obfuscation-commons-lang provides extensions to Apache Commons Lang for obfuscating objects.
- obfuscation-http provides support for obfuscating HTTP requests and responses.
- obfuscation-jackson and obfuscation-json provide support for obfuscating properties in JSON documents.
- obfuscation-xml provides support for obfuscating properties in XML documents.
- obfuscation-yaml provides support for obfuscating properties in YAML documents.
Package com.github.robtimus.obfuscation.support provides several classes that can be used to create custom obfuscators.
- obfuscation-annotations provides general purpose
Obfuscator
annotations. - obfuscation-jackson-databind provides integration with jackson-databind.
- obfuscation-spring provides integration with Spring and Spring Boot.