obfuscation-spring
Provides Spring and Spring Boot obfuscation support.
Add obfuscation-spring-boot-starter as a dependency to your project to get the following:
-
Autowire support for Obfuscator.
Instances of Obfuscator
can be autowired in two ways:
- Annotate an autowired field, constructor argument or method argument with any of the obfuscator annotations of obfuscation-annotations, and an instance of the matching obfuscator will be autowired.
- With no obfuscator annotation present, a default obfuscator is used.
-
Autowire support for Obfuscated.
Declaring an autowired field, constructor argument or method argument as Obfuscated
will automatically wrap the autowired field or argument. This supports both autowired values and beans.
The obfuscator to use is determined in one of two ways:
- Annotate the field or argument with any of the obfuscator annotations of obfuscation-annotations to use the matching obfuscation rules.
- With no obfuscator annotation present, a default obfuscator is used.
The character representation can be specified using @RepresentedBy. If this annotation is not present, the default character representation is used.
Examples:
@Autowired
@ObfuscateFixedLength(8)
private Obfuscator obfuscator;
@Autowired
private Obfuscator defaultObfuscator;
@Value("${property}")
@ObfuscateFixedLength(8)
private Obfuscated<String> obfuscatedValue;
@Autowired
@ObfuscateFixedLength(8)
@RepresentedBy(MyCharacterRepresentation.class)
private Obfuscated<MyBean> obfuscatedBean;
Default obfuscator
Out-of-the-box, the default obfuscator is Obfuscator.fixedLength(3). This can be overridden in two ways:
- Provide a custom bean of type Obfuscator.
- Define the default obfuscator in the application properties. See Properties for more information.
ObfuscatorProvider implementations
If an ObfuscatorProvider type is already available as a bean, this bean will be used. Otherwise, the type is instantiated using Spring's own bean factory. This allows implementations to use autowired fields.
Vanilla Spring
The automatic support for autowiring Obfuscator
and Obfuscated
only works when using obfuscation-spring-boot-starter
. To add obfuscation support to vanilla Spring: