]> WPIA git - gigi.git/blobdiff - util-testing/org/cacert/gigi/pages/Manager.java
add: display the configured timeouts and timespans for certain
[gigi.git] / util-testing / org / cacert / gigi / pages / Manager.java
index 6a4a521a7b730289ea1b4a8b338c63316b354914..c5b3c2571748564518a7c5b723c91324abd98057 100644 (file)
@@ -39,7 +39,8 @@ import org.cacert.gigi.dbObjects.Domain;
 import org.cacert.gigi.dbObjects.DomainPingType;
 import org.cacert.gigi.dbObjects.EmailAddress;
 import org.cacert.gigi.dbObjects.Group;
-import org.cacert.gigi.dbObjects.Name;
+import org.cacert.gigi.dbObjects.NamePart;
+import org.cacert.gigi.dbObjects.NamePart.NamePartType;
 import org.cacert.gigi.dbObjects.User;
 import org.cacert.gigi.email.EmailProvider;
 import org.cacert.gigi.localisation.Language;
@@ -51,6 +52,7 @@ import org.cacert.gigi.ping.PingerDaemon;
 import org.cacert.gigi.util.AuthorizationContext;
 import org.cacert.gigi.util.DayDate;
 import org.cacert.gigi.util.Notary;
+import org.cacert.gigi.util.TimeConditions;
 
 import sun.security.x509.X509Key;
 
@@ -109,7 +111,7 @@ public class Manager extends Page {
                 u = User.getByEmail(mail);
                 passCATS(u, CATSType.ASSURER_CHALLENGE);
                 ps.setInt(1, u.getId());
-                ps.setInt(2, u.getId());
+                ps.setInt(2, u.getPreferredName().getId());
                 ps.setInt(3, 100);
                 ps.setString(4, "Manager init code");
                 ps.setString(5, "1990-01-01");
@@ -203,7 +205,9 @@ public class Manager extends Page {
         Calendar gc = GregorianCalendar.getInstance();
         gc.setTimeInMillis(0);
         gc.set(1990, 0, 1);
-        User u = new User(email, "xvXV12°§", new Name("Först", "Läst", "Müddle", "Süffix"), new DayDate(gc.getTime().getTime()), Locale.ENGLISH);
+        User u = new User(email, "xvXV12°§", new DayDate(gc.getTime().getTime()), Locale.ENGLISH, //
+                new NamePart(NamePartType.FIRST_NAME, "Först"), new NamePart(NamePartType.FIRST_NAME, "Müddle"),//
+                new NamePart(NamePartType.LAST_NAME, "Läst"), new NamePart(NamePartType.SUFFIX, "Süffix"));
         EmailAddress ea = u.getEmails()[0];
         verify(email, ea);
     }
@@ -262,26 +266,51 @@ public class Manager extends Page {
             resp.getWriter().println("Test '" + test.getDisplayName() + "' was added to user account.");
         } else if (req.getParameter("assure") != null) {
             String mail = req.getParameter("assureEmail");
+            String verificationPoints = req.getParameter("verificationPoints");
             User byEmail = User.getByEmail(mail);
+
             if (byEmail == null) {
                 resp.getWriter().println("User not found.");
                 return;
             }
+
+            int vp = 0;
+            int agentNumber = 0;
+
             try {
-                for (int i = 0; i < 10; i++) {
-                    Notary.assure(getAssurer(i), byEmail, byEmail.getName(), byEmail.getDoB(), 10, "Testmanager Assure up code", "2014-11-06", AssuranceType.FACE_TO_FACE);
+                try {
+                    vp = Integer.parseInt(verificationPoints);
+                } catch (NumberFormatException e) {
+                    throw new GigiApiException("No valid Verification Points entered.");
                 }
+
+                if (vp > 100) { // only allow max 100 Verification points
+                    vp = 100;
+                }
+
+                while (vp > 0) {
+                    int currentVP = 10;
+                    if (vp < 10) {
+                        currentVP = vp;
+                    }
+                    Notary.assure(getAssurer(agentNumber), byEmail, byEmail.getPreferredName(), byEmail.getDoB(), currentVP, "Testmanager Assure up code", "2014-11-06", AssuranceType.FACE_TO_FACE);
+                    agentNumber += 1;
+                    vp -= currentVP;
+                }
+
             } catch (GigiApiException e) {
                 throw new Error(e);
             }
-            resp.getWriter().println("User has been assured.");
+
+            resp.getWriter().println("User has been assured " + agentNumber + " times.");
+
         } else if (req.getParameter("letassure") != null) {
             String mail = req.getParameter("letassureEmail");
             User byEmail = User.getByEmail(mail);
             try {
                 for (int i = 0; i < 25; i++) {
                     User a = getAssurer(i);
-                    Notary.assure(byEmail, a, a.getName(), a.getDoB(), 10, "Testmanager exp up code", "2014-11-06", AssuranceType.FACE_TO_FACE);
+                    Notary.assure(byEmail, a, a.getNames()[0], a.getDoB(), 10, "Testmanager exp up code", "2014-11-06", AssuranceType.FACE_TO_FACE);
                 }
             } catch (GigiApiException e) {
                 throw new Error(e);
@@ -400,6 +429,12 @@ public class Manager extends Page {
                 return true;
             }
         });
+
+        vars.put("testValidMonths", TimeConditions.getInstance().getTestMonths());
+        vars.put("reverificationDays", TimeConditions.getInstance().getVerificationLimitDays());
+        vars.put("verificationFreshMonths", TimeConditions.getInstance().getVerificationMonths());
+        vars.put("verificationMaxAgeMonths", TimeConditions.getInstance().getVerificationMaxAgeMonths());
+
         form.output(resp.getWriter(), getLanguage(req), vars);
     }
 }