-
Notifications
You must be signed in to change notification settings - Fork 285
/
credentialdata.mvel
73 lines (66 loc) · 1.9 KB
/
credentialdata.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
def convertDateFormat(value, inputformat, outputformat) {
import io.mosip.kernel.core.util.DateUtils;
import java.util.Date;
Date date=DateUtils.parseToDate(value, inputformat);
String formattedDate= DateUtils.formatDate(date, outputformat);
return formattedDate;
};
def convertToMaskData(maskData) {
int maskDataLength = 0;
char ch = 'X';
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 formatName(names) {
StringBuilder name = new StringBuilder("");
for (int i = 0; i < names.size(); i++) {
name.append(names[i]);
if(i < names.size() - 1) {
name.append(" ");
}
}
return name.toString()
};
def formatAddress(addressLines) {
StringBuilder address = new StringBuilder("");
for (int i = 0; i < addressLines.size(); i++) {
address.append(addressLines[i]);
if(i < addressLines.size() - 1) {
address.append(", ");
}
}
return address.toString()
};
def maskPhone(inputPhoneNum) {
return inputPhoneNum.replaceAll(".(?=.{4})", "*");
};
def maskEmail(inputEmailAddr) {
return inputEmailAddr.replaceAll("(^[^@]{3}|(?!^)\\G)[^@]", "$1*");
};
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();
}
};