forked from sjkarthik/mosip-config-nira
-
Notifications
You must be signed in to change notification settings - Fork 0
/
identity-data-formatter.mvel
46 lines (39 loc) · 1.17 KB
/
identity-data-formatter.mvel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
def maskPhone(inputPhoneNum) {
return inputPhoneNum.replaceAll(".(?=.{4})", "*");
};
def maskEmail(inputEmailAddr) {
return inputEmailAddr.replaceAll("(^[^@]{3}|(?!^)\\G)[^@]", "$1*");
};
def convertToMaskDataFormat(maskData) {
int maskDataLength = 0;
char ch = '*';
if (maskData.indexOf("@") > 0){
maskDataLength = maskData.indexOf("@");
} else {
maskDataLength = maskData.length();
}
maskDataLength -= 2;
for (int i = 1; i < maskDataLength; ++i) {
maskData = maskData.substring(0, i) + ch + maskData.substring(i + 1);
}
return maskData;
};
def getPassword(attributeValues) {
String pdfPwd = "";
for(String attribute:attributeValues) {
attribute = getFormattedPasswordAttribute(attribute);
pdfPwd = pdfPwd.concat(attribute.substring(0, 4));
}
return pdfPwd.toUpperCase();
};
def getFormattedPasswordAttribute(password){
if(password.length()==3){
return password=password.concat(password.substring(0,1));
}else if(password.length()==2){
return password=password.repeat(2);
}else if(password.length()==1) {
return password=password.repeat(4);
}else {
return password.toUpperCase();
}
};