]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/util/PasswordStrengthChecker.java
Adding stub for gigi-api (api.gigi.org)
[gigi.git] / src / org / cacert / gigi / util / PasswordStrengthChecker.java
index 373079922cb90f0414920bd153d9a63419073ab6..07898f263b681715f141d5405ce236bf4d07efd5 100644 (file)
@@ -9,10 +9,10 @@ public class PasswordStrengthChecker {
        static Pattern lower = Pattern.compile("[a-z]");
        static Pattern upper = Pattern.compile("[A-Z]");
        static Pattern whitespace = Pattern.compile("\\s");
-       static Pattern special = Pattern.compile("\\W");
+       static Pattern special = Pattern.compile("(?!\\s)\\W");
        private PasswordStrengthChecker() {
        }
-       public static int checkpwlight(String pw) {
+       private static int checkpwlight(String pw) {
                int points = 0;
                if (pw.length() > 15) {
                        points++;
@@ -44,6 +44,9 @@ public class PasswordStrengthChecker {
                return points;
        }
        public static int checkpw(String pw, User u) {
+               if (pw == null) {
+                       return 0;
+               }
                int light = checkpwlight(pw);
                if (contained(pw, u.getEmail())) {
                        light -= 2;
@@ -64,7 +67,7 @@ public class PasswordStrengthChecker {
                return light;
        }
        private static boolean contained(String pw, String check) {
-               if (check == null) {
+               if (check == null || check.equals("")) {
                        return false;
                }
                if (pw.contains(check)) {