]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/util/PasswordStrengthChecker.java
UPD: Cleanup User-class.
[gigi.git] / src / org / cacert / gigi / util / PasswordStrengthChecker.java
index e52c1dd07d080a5544fa3426bb3ed8a96e2d50e9..a1d2145075ceb94b69fef7442fa3588de4977f84 100644 (file)
@@ -3,19 +3,19 @@ package org.cacert.gigi.util;
 import java.util.regex.Pattern;
 
 import org.cacert.gigi.GigiApiException;
-import org.cacert.gigi.User;
+import org.cacert.gigi.dbObjects.Name;
 
 public class PasswordStrengthChecker {
 
-    static Pattern digits = Pattern.compile("\\d");
+    private static Pattern digits = Pattern.compile("\\d");
 
-    static Pattern lower = Pattern.compile("[a-z]");
+    private static Pattern lower = Pattern.compile("[a-z]");
 
-    static Pattern upper = Pattern.compile("[A-Z]");
+    private static Pattern upper = Pattern.compile("[A-Z]");
 
-    static Pattern whitespace = Pattern.compile("\\s");
+    private static Pattern whitespace = Pattern.compile("\\s");
 
-    static Pattern special = Pattern.compile("(?!\\s)\\W");
+    private static Pattern special = Pattern.compile("(?!\\s)\\W");
 
     private PasswordStrengthChecker() {}
 
@@ -51,32 +51,32 @@ public class PasswordStrengthChecker {
         return points;
     }
 
-    public static int checkpw(String pw, User u) {
+    public static int checkpw(String pw, Name name, String email) {
         if (pw == null) {
             return 0;
         }
         int light = checkpwlight(pw);
-        if (contained(pw, u.getEmail())) {
+        if (contained(pw, email)) {
             light -= 2;
         }
-        if (contained(pw, u.getFname())) {
+        if (contained(pw, name.getFname())) {
             light -= 2;
         }
-        if (contained(pw, u.getLname())) {
+        if (contained(pw, name.getLname())) {
             light -= 2;
         }
-        if (contained(pw, u.getMname())) {
+        if (contained(pw, name.getMname())) {
             light -= 2;
         }
-        if (contained(pw, u.getSuffix())) {
+        if (contained(pw, name.getSuffix())) {
             light -= 2;
         }
         // TODO dictionary check
         return light;
     }
 
-    public static void assertStrongPassword(String pw, User u) throws GigiApiException {
-        if (checkpw(pw, u) < 3) {
+    public static void assertStrongPassword(String pw, Name name, String email) throws GigiApiException {
+        if (checkpw(pw, name, email) < 3) {
             throw new GigiApiException("The Pass Phrase you submitted failed to contain enough" + " differing characters and/or contained words from" + " your name and/or email address.");
         }
     }