|
@@ -29,6 +29,8 @@ import java.util.Iterator;
|
|
|
import java.util.Map;
|
|
|
import java.util.Random;
|
|
|
import java.util.UUID;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
import javax.crypto.Cipher;
|
|
|
import javax.crypto.Mac;
|
|
@@ -639,4 +641,94 @@ public class LifeCenterFunction {
|
|
|
|
|
|
return strSymptom;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 패스워드를 규칙에 맞게 체크한다.
|
|
|
+ * [사용방법]
|
|
|
+ * LifeCenterFunction.checkPw(String inputPw);
|
|
|
+ * Return
|
|
|
+ * 0: OK (규칙에 부합됨)
|
|
|
+ * 1: 입력된 패스워드가 null이거나 없음.
|
|
|
+ * 2: 입력된 패스워드가 16자 이상임 15자리까지 입력가능.
|
|
|
+ * 3: 입력된 패스워드가 2조합 미만이고 10자리 미만.
|
|
|
+ * 4: 입력된 패스워드가 2조합인데, 8자리 미만임.
|
|
|
+ * 5:
|
|
|
+ * 6: 입력된 패스워드가 3자리 이상 연속된 값이 포함됨. (예, abc, def, 123)
|
|
|
+ * 7: 입력된 패스워드가 키보드 조합으로 3자리 이상 연속된 값이 포함됨. (예, asd, qwe, jkl)
|
|
|
+ * 8: 입력된 패스워드가 3자리 이상 같은 값이 포함됨. (예, aaa, 222)
|
|
|
+ * 99: 에러
|
|
|
+ */
|
|
|
+ public static String checkPw(String inputPw) {
|
|
|
+ String strResult = "";
|
|
|
+
|
|
|
+ if( inputPw == null || inputPw.equals("") ) return "1";
|
|
|
+ if( inputPw.length() > 15 ) return "2";
|
|
|
+
|
|
|
+ try {
|
|
|
+ Pattern pAlphabetLow = null;
|
|
|
+ Pattern pAlphabetUp = null;
|
|
|
+ Pattern pNumber = null;
|
|
|
+ Pattern pSpecialChar = null;
|
|
|
+ Pattern pThreeChar = null;
|
|
|
+ Matcher match;
|
|
|
+ int nCharType = 0;
|
|
|
+
|
|
|
+ pAlphabetLow = Pattern.compile("[a-z]"); // 영소문자
|
|
|
+ pAlphabetUp = Pattern.compile("[A-Z]"); // 영대문자
|
|
|
+ pNumber = Pattern.compile("[0-9]"); // 숫자
|
|
|
+ pSpecialChar = Pattern.compile("\\p{Punct}"); // 특수문자 -_=+\\|()*&^%$#@!~`?></;,.:'
|
|
|
+ pThreeChar = Pattern.compile("(\\p{Alnum})\\1{2,}");// 3자리 이상 같은 문자 또는 숫자
|
|
|
+
|
|
|
+ // 영소문자가 포함되어 있는가?
|
|
|
+ match = pAlphabetLow.matcher(inputPw);
|
|
|
+ if(match.find()) nCharType++;
|
|
|
+ // 영대문자가 포함되어 있는가?
|
|
|
+ match = pAlphabetUp.matcher(inputPw);
|
|
|
+ if(match.find()) nCharType++;
|
|
|
+ // 숫자가 포함되어 있는가?
|
|
|
+ match = pNumber.matcher(inputPw);
|
|
|
+ if(match.find()) nCharType++;
|
|
|
+ // 특수문자가 포함되어 있는가?
|
|
|
+ match = pSpecialChar.matcher(inputPw);
|
|
|
+ if(match.find()) nCharType++;
|
|
|
+
|
|
|
+ // 3자리 이상 같은 문자 또는 숫자가 포함되어 있는가?
|
|
|
+ match = pThreeChar.matcher(inputPw);
|
|
|
+ if(match.find()) return "8"; //입력된 패스워드가 3자리 이상 같은 값이 포함됨. (예, aaa, 222)
|
|
|
+
|
|
|
+ // 2가지 이상 조합인가?
|
|
|
+ if(nCharType >= 2) {
|
|
|
+ // 8자리 미만인경우
|
|
|
+ if(inputPw.length() < 8) return "4";
|
|
|
+ else strResult = "0";
|
|
|
+ } else {
|
|
|
+ //10자리 미만인 경우
|
|
|
+ if(inputPw.length() < 10) return "3";
|
|
|
+ else strResult = "0";
|
|
|
+ }
|
|
|
+
|
|
|
+ // 연속된 3자리 이상의 문자나 숫자가 포함되어 있는가?
|
|
|
+ String listThreeChar = "abc|bcd|cde|def|efg|fgh|ghi|hij|ijk|jkl|klm|lmn|mno|nop|opq|qrs|rst|stu|tuv|uvw|vwx|wxy|xyz|012|123|234|345|456|567|678|789|890";
|
|
|
+ String[] arrThreeChar = listThreeChar.split("\\|");
|
|
|
+ for (int i=0; i<arrThreeChar.length; i++) {
|
|
|
+ if(inputPw.toLowerCase().matches(".*" + arrThreeChar[i] + ".*")) {
|
|
|
+ return "6";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 연속된 3자리 이상의 키보드 문자가 포함되어 있는가?
|
|
|
+ String listKeyboardThreeChar = "qwe|wer|ert|rty|tyu|yui|uio|iop|asd|sdf|dfg|fgh|ghj|hjk|jkl|zxc|xcv|cvb|vbn|bnm";
|
|
|
+ String[] arrKeyboardThreeChar = listKeyboardThreeChar.split("\\|");
|
|
|
+ for (int j=0; j<arrKeyboardThreeChar.length; j++) {
|
|
|
+ if(inputPw.toLowerCase().matches(".*" + arrKeyboardThreeChar[j] + ".*")) {
|
|
|
+ return "7";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception ex) {
|
|
|
+ strResult = "99";
|
|
|
+ }
|
|
|
+
|
|
|
+ return strResult;
|
|
|
+ }
|
|
|
}
|