import club.wpia.gigi.dbObjects.Certificate;
import club.wpia.gigi.dbObjects.Certificate.CertificateStatus;
import club.wpia.gigi.dbObjects.CertificateOwner;
+import club.wpia.gigi.dbObjects.Contract;
+import club.wpia.gigi.dbObjects.Contract.ContractType;
import club.wpia.gigi.dbObjects.Country;
import club.wpia.gigi.dbObjects.Digest;
import club.wpia.gigi.dbObjects.Domain;
ps.setString(6, getRandomCountry().getCode());
ps.execute();
}
+ new Contract(u, ContractType.RA_AGENT_CONTRACT);
return u;
}
}
}
int vp = 0;
- int agentNumber = 0;
+ int verifications = 0;
+ String info = "";
try {
try {
vp = Integer.parseInt(verificationPoints);
} catch (NumberFormatException e) {
- throw new GigiApiException("No valid Verification Points entered.");
+ resp.getWriter().println("The value for Verification Points must be an integer.</br>");
+ vp = 0;
}
- if (vp > 100) { // only allow max 100 Verification points
- vp = 100;
- }
+ int agentNumber = addVerificationPoints(vp, byEmail);
while (vp > 0) {
int currentVP = 10;
if (vp < 10) {
currentVP = vp;
}
- Notary.verify(getAgent(agentNumber), byEmail, byEmail.getPreferredName(), byEmail.getDoB(), currentVP, "Testmanager Verify up code", validVerificationDateString(), VerificationType.FACE_TO_FACE, getRandomCountry());
+ if (Notary.checkVerificationIsPossible(getAgent(agentNumber), byEmail.getPreferredName())) {
+
+ Notary.verify(getAgent(agentNumber), byEmail, byEmail.getPreferredName(), byEmail.getDoB(), currentVP, "Testmanager Verify up code", validVerificationDateString(), VerificationType.FACE_TO_FACE, getRandomCountry());
+ vp -= currentVP;
+ verifications += 1;
+
+ }
agentNumber += 1;
- vp -= currentVP;
+ if (agentNumber >= agents.length) {
+ info = "<br/>The limit of agents is reached. You cannot add any more Verification Points to the preferred name of this user using this method.";
+ break;
+ }
}
} catch (GigiApiException e) {
throw new Error(e);
}
- resp.getWriter().println("User has been verified " + agentNumber + " times.");
+ resp.getWriter().println("User has been verified " + verifications + " times." + info);
} else if (req.getParameter("letverify") != null) {
String mail = req.getParameter("letverifyEmail");
pingExempt.remove(dom);
resp.getWriter().println("Updated domains exempt from pings. Current set: <br/>");
resp.getWriter().println(HTMLEncoder.encodeHTML(pingExempt.toString()));
+ } else if (req.getParameter("makeAgent") != null) {
+ User u = User.getByEmail(req.getParameter("agentEmail"));
+ if (u == null) {
+ resp.getWriter().println("User not found, or found user is not allowed to verify.");
+ } else {
+ if (u.getVerificationPoints() < 100) {
+ addVerificationPoints(100, u);
+ }
+ if ( !u.hasPassedCATS()) {
+ passCATS(u, CATSType.AGENT_CHALLENGE);
+ }
+ if ( !Contract.hasSignedContract(u, Contract.ContractType.RA_AGENT_CONTRACT)) {
+ try {
+ new Contract(u, Contract.ContractType.RA_AGENT_CONTRACT);
+ } catch (GigiApiException e) {
+ throw new Error(e);
+ }
+ }
+ resp.getWriter().println("User has all requirements to be an RA Agent");
+ }
}
resp.getWriter().println("<br/><a href='" + PATH + "'>Go back</a>");
}
+ private int addVerificationPoints(int vp, User byEmail) throws Error {
+ int agentNumber = 0;
+
+ try {
+ if (vp > 100) { // only allow max 100 Verification points
+ vp = 100;
+ }
+
+ while (vp > 0) {
+ int currentVP = 10;
+ if (vp < 10) {
+ currentVP = vp;
+ }
+ Notary.verify(getAgent(agentNumber), byEmail, byEmail.getPreferredName(), byEmail.getDoB(), currentVP, "Testmanager Verify up code", validVerificationDateString(), VerificationType.FACE_TO_FACE, getRandomCountry());
+ agentNumber += 1;
+ vp -= currentVP;
+ }
+
+ } catch (GigiApiException e) {
+ throw new Error(e);
+ }
+ return agentNumber;
+ }
+
private void fetchMails(HttpServletRequest req, HttpServletResponse resp, String mail) throws IOException {
final LinkedList<String> mails = emails.get(mail);
HashMap<String, Object> vars = new HashMap<>();