obfuscation-core
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.
Streaming obfuscation
An Obfuscator has method streamTo which takes a StringBuilder, Writer or other Appendable, and returns a Writer that will obfuscate the written text automatically.
Preventing leaking string representations
The following methods of Obfuscator can be used to help prevent accidentally leaking string representations of objects, for instance by logging them:
obfuscateList,obfuscateSetandobfuscateCollectioncreateList,SetandCollectiondecorators respectively that obfuscate separate elements when callingtoString().obfuscateMapcreates aMapdecorator that obfuscates separate values (but not keys) when callingtoString().obfuscateObjectcreates a wrapper around an existing object that obfuscates the object when callingtoString().
Obfuscating complex structures
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.
Writing custom obfucators
Package com.github.robtimus.obfuscation.support provides several classes that can be used to create custom obfuscators.
Extensions
- obfuscation-annotations provides general purpose
Obfuscatorannotations. - obfuscation-jackson-databind provides integration with jackson-databind.
- obfuscation-spring provides integration with Spring and Spring Boot.
