/** * @version: V1.0 * @author: zhang yang * @className: checkSimplePWD * @packageName: checkSimplePWD * @description: Check Simple password * @data: 2020-06-29 * @param: (String)LoginUserPwd * @return: * true : simple pwd * false : not simple pwd * * * Simple password verify rule: * 1. password = userid & username ; password include userid * 2. password length < 8 * 3. password same numbers more than 3 , Like: 1111,aaaa * 4. serial char more than 4, Like: 1234,4567 * 5. password is all numbers * 6. password is all low char * 7. password is all large char * */ import java.util.regex.*; public class checkSimplePWD { public static boolean isSimple(String LoginUserPwd) { Pattern pat = Pattern.compile("(.)\\1{3}"); // \\1 means match 1 group,{2} means repeat 2+1 times Matcher pmt = pat.matcher(LoginUserPwd); if( pmt.find() ) { return true; } Pattern patternN = Pattern.compile("[0-9]*"); if(patternN.matcher(LoginUserPwd).matches()==true) { return true; } Pattern patternC1 = Pattern.compile("[a-z]*"); if(patternC1.matcher(LoginUserPwd).matches()==true) { return true; } Pattern patternC2 = Pattern.compile("[A-Z]*"); if(patternC2.matcher(LoginUserPwd).matches()==true) { return true; } String strPat[] = {"0123","1234","2345","3456","4567","5678","6789","7890"}; for(int p1=0;p1-1) { return true; } } return false; } public static void main(String args[]) { checkSimplePWD sp = new checkSimplePWD(); System.out.println(sp.isSimple(args[0])); } }