]> 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 6889bfbe908ba43aef89a43df2c831c1dac26374..c5b3c2571748564518a7c5b723c91324abd98057 100644 (file)
@@ -52,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;
 
@@ -110,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");
@@ -265,19 +266,44 @@ 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.getPreferredName(), 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);
@@ -403,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);
     }
 }