X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=util-testing%2Forg%2Fcacert%2Fgigi%2Fpages%2FManager.java;h=21b7e43218d907342d22480b52cd6332809fd7a8;hb=6fdaa05e2fc9f65211d3c8c5bda894b3c1906d2c;hp=6889bfbe908ba43aef89a43df2c831c1dac26374;hpb=9def69bd08ea69eb27786d5b34f00e154e09e9f3;p=gigi.git diff --git a/util-testing/org/cacert/gigi/pages/Manager.java b/util-testing/org/cacert/gigi/pages/Manager.java index 6889bfbe..21b7e432 100644 --- a/util-testing/org/cacert/gigi/pages/Manager.java +++ b/util-testing/org/cacert/gigi/pages/Manager.java @@ -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; @@ -105,12 +106,12 @@ public class Manager extends Page { String mail = "test-assurer" + i + "@example.com"; User u = User.getByEmail(mail); if (u == null) { - System.out.println("Creating assurer"); + System.out.println("Creating RA-Agent"); createUser(mail); 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 Verify 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); } }