The core functionality of this tool is similar to the method toString() in a java domain object, but it scan the @Mask
annotation and masks the values of the confidential information.
It will scan through the object graph deeper and finds the @Mask
annotation and manipulates the values.
Installation
<dependency>
<groupId>com.immibytes</groupId>
<artifactId>sp-utils</artifactId>
<version>1.0.0-RELEASE</version>
</dependency>
How to use
- Specify the annotation @Mask in the java domain object.
public class UserInfo{
@Mask
private String emailId = "[email protected]";
private boolean online = true;
private List<ContactNumber> instances = new ArrayList<>();
}
- Initialize the MaskLogger and use the toString method, pass the domain object.
UserInfo instance = new UserInfo();
MaskLogger maskLogger= new MaskLogger();
String maskedString = maskLogger.toString(instance);
System.out.println(maskedString); // Print as: [emailId=XX, online=true,instances=[]]
Note: If you using it in the spring application, initialize using below
<bean id="maskLogger" class="com.immibytes.util.log.MaskLogger"/>