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,- obfuscateSetand- obfuscateCollectioncreate- List,- Setand- Collectiondecorators respectively that obfuscate separate elements when calling- toString().
- obfuscateMapcreates a- Mapdecorator that obfuscates separate values (but not keys) when calling- toString().
- obfuscateObjectcreates a wrapper around an existing object that obfuscates the object when calling- toString().
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 Obfuscatorfor each entry. Entries can even have no obfuscation at all.
- PropertiesObfuscator can obfuscate Propertiesobjects by providing a separateObfuscatorfor 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 Obfuscatorannotations.
- obfuscation-jackson-databind provides integration with jackson-databind.
- obfuscation-spring provides integration with Spring and Spring Boot.