]> WPIA git - gigi.git/commitdiff
add: country information where verification took place
authorINOPIAE <m.maengel@inopiae.de>
Mon, 18 Jul 2016 09:27:56 +0000 (11:27 +0200)
committerINOPIAE <m.maengel@inopiae.de>
Sat, 13 Aug 2016 15:12:04 +0000 (17:12 +0200)
fixes issue #78

Change-Id: I0e677dfc0dde671a95186f9c64388fad2da4446b

17 files changed:
doc/Data.uxf
src/org/cacert/gigi/database/DatabaseConnection.java
src/org/cacert/gigi/database/tableStructure.sql
src/org/cacert/gigi/database/upgrade/from_21.sql [new file with mode: 0644]
src/org/cacert/gigi/dbObjects/Assurance.java
src/org/cacert/gigi/dbObjects/User.java
src/org/cacert/gigi/output/AssurancesDisplay.java
src/org/cacert/gigi/pages/wot/AssuranceForm.java
src/org/cacert/gigi/pages/wot/AssuranceForm.templ
src/org/cacert/gigi/util/Notary.java
tests/org/cacert/gigi/TestUser.java
tests/org/cacert/gigi/dbObjects/TestAssuranceMail.java
tests/org/cacert/gigi/dbObjects/TestAssureName.java
tests/org/cacert/gigi/pages/account/TestPasswordResetExternal.java
tests/org/cacert/gigi/pages/wot/TestAssurance.java
tests/org/cacert/gigi/util/TestNotary.java
util-testing/org/cacert/gigi/pages/Manager.java

index 8854e2655797e8002bb6f25db61323ae130e4338..225ae2d2436606b9a3e3a48382b9c8738c24ef16 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<diagram program="umlet" version="14.2">
+<diagram program="umlet" version="14.2.0">
   <zoom_level>10</zoom_level>
   <element>
     <type>com.baselet.element.old.element.Class</type>
@@ -318,7 +318,7 @@ executed as&gt;</panel_attributes>
       <x>710</x>
       <y>1090</y>
       <w>390</w>
-      <h>180</h>
+      <h>200</h>
     </coordinates>
     <panel_attributes>Assurance
 --
@@ -331,6 +331,7 @@ executed as&gt;</panel_attributes>
 -expire: timestamp
 -sponsor: User (??????????)
 -deleted: timestamp
+-country: varchar(2)
 </panel_attributes>
     <additional_attributes/>
   </element>
@@ -351,14 +352,14 @@ Assurer&gt;</panel_attributes>
     <type>com.baselet.element.old.element.Relation</type>
     <coordinates>
       <x>580</x>
-      <y>1060</y>
+      <y>1070</y>
       <w>150</w>
-      <h>70</h>
+      <h>80</h>
     </coordinates>
     <panel_attributes>lt=-
 m1=0..n
 Assuree&gt;</panel_attributes>
-    <additional_attributes>130;50;30;50</additional_attributes>
+    <additional_attributes>130;60;30;40</additional_attributes>
   </element>
   <element>
     <type>com.baselet.element.old.element.Class</type>
index 80f96e8d68504701987761e129729561c013f82f..d9febb087fc2bdbe0a570246b994428551cd7672 100644 (file)
@@ -122,7 +122,7 @@ public class DatabaseConnection {
 
     }
 
-    public static final int CURRENT_SCHEMA_VERSION = 21;
+    public static final int CURRENT_SCHEMA_VERSION = 22;
 
     public static final int CONNECTION_TIMEOUT = 24 * 60 * 60;
 
index f9010ccb296774c4b61062a0b51c90b3d435e4d8..a8d92f57dca3879a8c39aa2ddd5bb51c5b956598 100644 (file)
@@ -271,6 +271,7 @@ CREATE TABLE "notary" (
   "sponsor" int NOT NULL DEFAULT '0',
 # date when verification was deleted (or 0)
   "deleted" timestamp NULL DEFAULT NULL,
+  "country" varchar(2) NULL,
   PRIMARY KEY ("id")
 );
 
@@ -372,7 +373,7 @@ CREATE TABLE "schemeVersion" (
   "version" smallint NOT NULL,
   PRIMARY KEY ("version")
 );
-INSERT INTO "schemeVersion" (version)  VALUES(21);
+INSERT INTO "schemeVersion" (version)  VALUES(22);
 
 DROP TABLE IF EXISTS `passwordResetTickets`;
 CREATE TABLE `passwordResetTickets` (
diff --git a/src/org/cacert/gigi/database/upgrade/from_21.sql b/src/org/cacert/gigi/database/upgrade/from_21.sql
new file mode 100644 (file)
index 0000000..e565d9f
--- /dev/null
@@ -0,0 +1 @@
+ALTER TABLE "notary" ADD COLUMN  "country" varchar(2) NULL;
index dbcc20b6c2f290c75b842e2e35c4784c37b6eb98..486b5a340d2b468010a9d16d9564c3da422d7ac4 100644 (file)
@@ -33,7 +33,9 @@ public class Assurance {
 
     private String date;
 
-    public Assurance(int id, User from, Name to, String location, String method, int points, String date) {
+    private CountryCode country;
+
+    public Assurance(int id, User from, Name to, String location, String method, int points, String date, CountryCode country) {
         this.id = id;
         this.from = from;
         this.to = to;
@@ -41,6 +43,7 @@ public class Assurance {
         this.method = method;
         this.points = points;
         this.date = date;
+        this.country = country;
 
     }
 
@@ -72,4 +75,7 @@ public class Assurance {
         return date;
     }
 
+    public CountryCode getCountry() {
+        return country;
+    }
 }
index 009814762ec89ecb40df9cfecd045bf9374a0c57..a6e1d3f13c3abb43a776cdbdde0e4b5b4839cb0e 100644 (file)
@@ -16,6 +16,7 @@ import org.cacert.gigi.database.GigiPreparedStatement;
 import org.cacert.gigi.database.GigiResultSet;
 import org.cacert.gigi.dbObjects.Assurance.AssuranceType;
 import org.cacert.gigi.dbObjects.CATS.CATSType;
+import org.cacert.gigi.dbObjects.CountryCode.CountryCodeType;
 import org.cacert.gigi.localisation.Language;
 import org.cacert.gigi.output.DateSelector;
 import org.cacert.gigi.pages.PasswordResetPage;
@@ -595,7 +596,11 @@ public class User extends CertificateOwner {
     }
 
     private Assurance assuranceByRes(GigiResultSet res) {
-        return new Assurance(res.getInt("id"), User.getById(res.getInt("from")), Name.getById(res.getInt("to")), res.getString("location"), res.getString("method"), res.getInt("points"), res.getString("date"));
+        try {
+            return new Assurance(res.getInt("id"), User.getById(res.getInt("from")), Name.getById(res.getInt("to")), res.getString("location"), res.getString("method"), res.getInt("points"), res.getString("date"), res.getString("country") == null ? null : CountryCode.getCountryCode(res.getString("country"), CountryCodeType.CODE_2_CHARS));
+        } catch (GigiApiException e) {
+            throw new Error(e);
+        }
     }
 
     public boolean isInVerificationLimit() {
index f6d5362a62a4d0223f8a5a2122187616b5d20154..c412a4eb7b4ee7324fb31061c5d3823d14fb67b6 100644 (file)
@@ -60,7 +60,7 @@ public class AssurancesDisplay implements Outputable {
                         vars.put("myName", to == null ? l.getTranslation("own name removed") : to);
                     }
                     vars.put("date", assurance.getDate());
-                    vars.put("location", assurance.getLocation());
+                    vars.put("location", assurance.getLocation() + " (" + (assurance.getCountry() == null ? l.getTranslation("not given") : assurance.getCountry().getCountry()) + ")");
                     vars.put("points", assurance.getPoints());
                     i++;
                     return true;
index e5521dab20b3ca251798811995d5c048502bad74..8ad735fbd8b78e48f0c261a05d73c1fa0c235443 100644 (file)
@@ -17,6 +17,7 @@ import org.cacert.gigi.dbObjects.Name;
 import org.cacert.gigi.dbObjects.User;
 import org.cacert.gigi.localisation.Language;
 import org.cacert.gigi.output.ArrayIterable;
+import org.cacert.gigi.output.CountrySelector;
 import org.cacert.gigi.output.template.Form;
 import org.cacert.gigi.output.template.IterableDataset;
 import org.cacert.gigi.output.template.SprintfCommand;
@@ -48,6 +49,8 @@ public class AssuranceForm extends Form {
 
     private static final Template templ = new Template(AssuranceForm.class.getResource("AssuranceForm.templ"));
 
+    private CountrySelector cs;
+
     public AssuranceForm(HttpServletRequest hsr, User assuree) throws GigiApiException {
         super(hsr);
         assurer = Page.getUser(hsr);
@@ -73,6 +76,7 @@ public class AssuranceForm extends Form {
         assureeNames = names.toArray(new Name[names.size()]);
         dob = this.assuree.getDoB();
         selected = new boolean[assureeNames.length];
+        cs = new CountrySelector("countryCode", false);
     }
 
     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
@@ -100,6 +104,8 @@ public class AssuranceForm extends Form {
         res.put("location", location);
         res.put("date", date);
         res.put("aword", aword);
+        res.put("countryCode", cs);
+
         final LinkedList<AssuranceType> ats = new LinkedList<>();
         for (AssuranceType at : AssuranceType.values()) {
             try {
@@ -131,6 +137,7 @@ public class AssuranceForm extends Form {
     public boolean submit(PrintWriter out, HttpServletRequest req) throws GigiApiException {
         location = req.getParameter("location");
         date = req.getParameter("date");
+        cs.update(req);
         GigiApiException gae = new GigiApiException();
         if (date == null || location == null) {
             gae.mergeInto(new GigiApiException("You need to enter location and date!"));
@@ -187,7 +194,7 @@ public class AssuranceForm extends Form {
             throw new GigiApiException("You must confirm at least one name to verify an account.");
         }
 
-        Notary.assureAll(assurer, assuree, dob, pointsI, location, req.getParameter("date"), type, toAssure.toArray(new Name[toAssure.size()]));
+        Notary.assureAll(assurer, assuree, dob, pointsI, location, req.getParameter("date"), type, toAssure.toArray(new Name[toAssure.size()]), cs.getCountry());
 
         if (aword != null && !aword.equals("")) {
             Language langApplicant = Language.getInstance(assuree.getPreferredLocale());
index 297397c62e34fccba775503310d42721b6044bc3..f846bc9641a69589ef0590df79fff5d6bf8fc680 100644 (file)
                <td><input type="checkbox" name="certify" value="1" required></td>
                <td><?=_I certify that ${name} has appeared in person.?></td>
        </tr>
+       <tr>
+               <td><?=_Location Country?></td>
+               <td>
+                       <?=$countryCode?>
+               </td>
+       </tr>
        <tr>
                <td><?=_Location?></td>
                <td><input class="form-control" type="text" name="location" value="<?=$location?>" required></td>
index ed1ce238c93d144cd04da9ca42230df36600a25b..f43e3195038ea89b56ae2c7925efd4a857c66f48 100644 (file)
@@ -12,6 +12,7 @@ import org.cacert.gigi.GigiApiException;
 import org.cacert.gigi.database.GigiPreparedStatement;
 import org.cacert.gigi.database.GigiResultSet;
 import org.cacert.gigi.dbObjects.Assurance.AssuranceType;
+import org.cacert.gigi.dbObjects.CountryCode;
 import org.cacert.gigi.dbObjects.Group;
 import org.cacert.gigi.dbObjects.Name;
 import org.cacert.gigi.dbObjects.User;
@@ -80,7 +81,7 @@ public class Notary {
      * @throws GigiApiException
      *             if the assurance fails (for various reasons)
      */
-    public synchronized static void assure(User assurer, User assuree, Name assureeName, DayDate dob, int awarded, String location, String date, AssuranceType type) throws GigiApiException {
+    public synchronized static void assure(User assurer, User assuree, Name assureeName, DayDate dob, int awarded, String location, String date, AssuranceType type, CountryCode country) throws GigiApiException {
         may(assurer, assuree, AssuranceType.FACE_TO_FACE);
         GigiApiException gae = new GigiApiException();
         if ( !gae.isEmpty()) {
@@ -112,6 +113,11 @@ public class Notary {
         } else if (location.length() <= 2) {
             gae.mergeInto(new GigiApiException("You must enter a location with at least 3 characters eg town and country."));
         }
+
+        if (country == null) {
+            gae.mergeInto(new GigiApiException("You failed to enter the country of your meeting."));
+        }
+
         synchronized (assuree) {
             if (assurer.getId() == assuree.getId()) {
                 throw new GigiApiException("You cannot verify yourself.");
@@ -150,11 +156,11 @@ public class Notary {
             }
 
             if (type == AssuranceType.FACE_TO_FACE) {
-                assureF2F(assurer, assuree, assureeName, awarded, location, date);
+                assureF2F(assurer, assuree, assureeName, awarded, location, date, country);
             } else if (type == AssuranceType.NUCLEUS) {
-                assureNucleus(assurer, assuree, assureeName, awarded, location, date);
+                assureNucleus(assurer, assuree, assureeName, awarded, location, date, country);
             } else if (type == AssuranceType.TTP_ASSISTED) {
-                assureTTP(assurer, assuree, assureeName, awarded, location, date);
+                assureTTP(assurer, assuree, assureeName, awarded, location, date, country);
             } else {
                 throw new GigiApiException(SprintfCommand.createSimple("Unknown Verification type: {0}", type.toString()));
             }
@@ -163,26 +169,28 @@ public class Notary {
         }
     }
 
-    private static void assureF2F(User assurer, User assuree, Name name, int awarded, String location, String date) throws GigiApiException {
+    private static void assureF2F(User assurer, User assuree, Name name, int awarded, String location, String date, CountryCode country) throws GigiApiException {
         may(assurer, assuree, AssuranceType.FACE_TO_FACE);
-        try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?")) {
+        try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?, `country`=?")) {
             ps.setInt(1, assurer.getId());
             ps.setInt(2, name.getId());
             ps.setInt(3, awarded);
             ps.setString(4, location);
             ps.setString(5, date);
+            ps.setString(6, country.getCountryCode());
             ps.execute();
         }
     }
 
-    private static void assureTTP(User assurer, User assuree, Name name, int awarded, String location, String date) throws GigiApiException {
+    private static void assureTTP(User assurer, User assuree, Name name, int awarded, String location, String date, CountryCode country) throws GigiApiException {
         may(assurer, assuree, AssuranceType.TTP_ASSISTED);
-        try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?, `method`='TTP-Assisted'")) {
+        try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?, `country`=?, `method`='TTP-Assisted'")) {
             ps.setInt(1, assurer.getId());
             ps.setInt(2, name.getId());
             ps.setInt(3, awarded);
             ps.setString(4, location);
             ps.setString(5, date);
+            ps.setString(6, country.getCountryCode());
             ps.execute();
             assuree.revokeGroup(assurer, Group.TTP_APPLICANT);
         }
@@ -215,11 +223,11 @@ public class Notary {
         throw new GigiApiException("Verification type not possible.");
     }
 
-    private static void assureNucleus(User assurer, User assuree, Name name, int awarded, String location, String date) throws GigiApiException {
+    private static void assureNucleus(User assurer, User assuree, Name name, int awarded, String location, String date, CountryCode country) throws GigiApiException {
         may(assurer, assuree, AssuranceType.NUCLEUS);
         // Do up to 35 points as f2f
         int f2fPoints = Math.min(assurer.getMaxAssurePoints(), awarded);
-        assureF2F(assurer, assuree, name, f2fPoints, location, date);
+        assureF2F(assurer, assuree, name, f2fPoints, location, date, country);
 
         awarded -= f2fPoints;
         if (awarded <= 0) {
@@ -228,17 +236,18 @@ public class Notary {
 
         // Assure remaining points as "Nucleus Bonus"
         // Valid for 4 Weeks = 28 days
-        try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?, `method`='Nucleus Bonus', `expire` = CURRENT_TIMESTAMP + interval '28 days'")) {
+        try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?, `country`=?, `method`='Nucleus Bonus', `expire` = CURRENT_TIMESTAMP + interval '28 days'")) {
             ps.setInt(1, assurer.getId());
             ps.setInt(2, name.getId());
             ps.setInt(3, awarded);
             ps.setString(4, location);
             ps.setString(5, date);
+            ps.setString(6, country.getCountryCode());
             ps.execute();
         }
     }
 
-    public synchronized static void assureAll(User assurer, User assuree, DayDate dob, int awarded, String location, String date, AssuranceType type, Name[] toAssure) throws GigiApiException {
+    public synchronized static void assureAll(User assurer, User assuree, DayDate dob, int awarded, String location, String date, AssuranceType type, Name[] toAssure, CountryCode country) throws GigiApiException {
         if (toAssure.length == 0) {
             throw new GigiApiException("You must confirm at least one name to verify an account.");
         }
@@ -247,7 +256,7 @@ public class Notary {
         for (int i = 0; i < toAssure.length; i++) {
             hadLessThan50Points[i] = toAssure[i].getAssurancePoints() < 50;
 
-            assure(assurer, assuree, toAssure[i], dob, awarded, location, date, type);
+            assure(assurer, assuree, toAssure[i], dob, awarded, location, date, type, country);
         }
         sendVerificationNotificationApplicant(assurer, assuree, toAssure, awarded, hadLessThan50Points, hadTotalLessThan100);
     }
index f665a7a6958c354ccc9bbe8369e65eaedb2b4a81..ff67b4f290ded70f05a15fa31c6992364466af0d 100644 (file)
@@ -9,6 +9,8 @@ import java.util.Locale;
 
 import org.cacert.gigi.dbObjects.Assurance;
 import org.cacert.gigi.dbObjects.Assurance.AssuranceType;
+import org.cacert.gigi.dbObjects.CountryCode;
+import org.cacert.gigi.dbObjects.CountryCode.CountryCodeType;
 import org.cacert.gigi.dbObjects.Domain;
 import org.cacert.gigi.dbObjects.EmailAddress;
 import org.cacert.gigi.dbObjects.Name;
@@ -109,7 +111,7 @@ public class TestUser extends BusinessTest {
         User[] us = new User[5];
         for (int i = 0; i < us.length; i++) {
             us[i] = User.getById(createAssuranceUser("f", "l", createUniqueName() + "@email.com", TEST_PASSWORD));
-            Notary.assure(us[i], u, u.getPreferredName(), u.getDoB(), 10, "here", validVerificationDateString(), AssuranceType.FACE_TO_FACE);
+            Notary.assure(us[i], u, u.getPreferredName(), u.getDoB(), 10, "here", validVerificationDateString(), AssuranceType.FACE_TO_FACE, CountryCode.getCountryCode("DE", CountryCodeType.CODE_2_CHARS));
         }
 
         assertTrue(u.isValidName("aä b"));
index dcb450396486e44a37f67c434b946249766494f8..d8661811d6f5aca1b2bf10498d41e9bdb87850b5 100644 (file)
@@ -8,10 +8,8 @@ import java.sql.Timestamp;
 import org.cacert.gigi.GigiApiException;
 import org.cacert.gigi.database.GigiPreparedStatement;
 import org.cacert.gigi.dbObjects.Assurance.AssuranceType;
-import org.cacert.gigi.dbObjects.Name;
-import org.cacert.gigi.dbObjects.NamePart;
+import org.cacert.gigi.dbObjects.CountryCode.CountryCodeType;
 import org.cacert.gigi.dbObjects.NamePart.NamePartType;
-import org.cacert.gigi.dbObjects.User;
 import org.cacert.gigi.testUtils.BusinessTest;
 import org.cacert.gigi.util.DayDate;
 import org.cacert.gigi.util.Notary;
@@ -48,7 +46,7 @@ public class TestAssuranceMail extends BusinessTest {
             int applicantId = createVerifiedUser("John", "Doe", applicantT, TEST_PASSWORD);
             User applicantXP = User.getById(applicantId);
             applicantXP = User.getById(applicantId);
-            Notary.assure(agentXP, applicantXP, applicantXP.getNames()[0], applicantXP.getDoB(), 10, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE);
+            Notary.assure(agentXP, applicantXP, applicantXP.getNames()[0], applicantXP.getDoB(), 10, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE, CountryCode.getCountryCode("DE", CountryCodeType.CODE_2_CHARS));
         }
     }
 
@@ -57,7 +55,7 @@ public class TestAssuranceMail extends BusinessTest {
     }
 
     private void enterVerification(int points, Name... names) throws GigiApiException {
-        Notary.assureAll(agent, applicant, applicant.getDoB(), points, createUniqueName(), validVerificationDateString(), AssuranceType.FACE_TO_FACE, names);
+        Notary.assureAll(agent, applicant, applicant.getDoB(), points, createUniqueName(), validVerificationDateString(), AssuranceType.FACE_TO_FACE, names, CountryCode.getCountryCode("DE", CountryCodeType.CODE_2_CHARS));
     }
 
     private void enterVerificationInPast(int points, Name name) {
@@ -275,20 +273,20 @@ public class TestAssuranceMail extends BusinessTest {
 
         // verify with 35 VP
         newAgent();
-        Notary.assure(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 10, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE);
-        Notary.assure(agent, applicant, applicant.getNames()[1], applicant.getDoB(), 10, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE);
+        Notary.assure(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 10, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE, CountryCode.getCountryCode("DE", CountryCodeType.CODE_2_CHARS));
+        Notary.assure(agent, applicant, applicant.getNames()[1], applicant.getDoB(), 10, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE, CountryCode.getCountryCode("DE", CountryCodeType.CODE_2_CHARS));
 
         newAgent();
-        Notary.assure(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 10, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE);
-        Notary.assure(agent, applicant, applicant.getNames()[1], applicant.getDoB(), 10, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE);
+        Notary.assure(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 10, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE, CountryCode.getCountryCode("DE", CountryCodeType.CODE_2_CHARS));
+        Notary.assure(agent, applicant, applicant.getNames()[1], applicant.getDoB(), 10, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE, CountryCode.getCountryCode("DE", CountryCodeType.CODE_2_CHARS));
 
         newAgent();
-        Notary.assure(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 10, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE);
-        Notary.assure(agent, applicant, applicant.getNames()[1], applicant.getDoB(), 10, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE);
+        Notary.assure(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 10, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE, CountryCode.getCountryCode("DE", CountryCodeType.CODE_2_CHARS));
+        Notary.assure(agent, applicant, applicant.getNames()[1], applicant.getDoB(), 10, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE, CountryCode.getCountryCode("DE", CountryCodeType.CODE_2_CHARS));
 
         newAgent();
-        Notary.assure(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 5, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE);
-        Notary.assure(agent, applicant, applicant.getNames()[1], applicant.getDoB(), 5, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE);
+        Notary.assure(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 5, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE, CountryCode.getCountryCode("DE", CountryCodeType.CODE_2_CHARS));
+        Notary.assure(agent, applicant, applicant.getNames()[1], applicant.getDoB(), 5, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE, CountryCode.getCountryCode("DE", CountryCodeType.CODE_2_CHARS));
 
         // add first Verification in the past result first name 45 VP
         newAgent();
@@ -304,16 +302,16 @@ public class TestAssuranceMail extends BusinessTest {
 
         // verify first name to 85 VP
         newAgent();
-        Notary.assure(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 10, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE);
+        Notary.assure(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 10, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE, CountryCode.getCountryCode("DE", CountryCodeType.CODE_2_CHARS));
 
         newAgent();
-        Notary.assure(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 10, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE);
+        Notary.assure(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 10, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE, CountryCode.getCountryCode("DE", CountryCodeType.CODE_2_CHARS));
 
         newAgent();
-        Notary.assure(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 10, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE);
+        Notary.assure(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 10, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE, CountryCode.getCountryCode("DE", CountryCodeType.CODE_2_CHARS));
 
         newAgent();
-        Notary.assure(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 5, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE);
+        Notary.assure(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 5, "Test location", "2014-11-06", AssuranceType.FACE_TO_FACE, CountryCode.getCountryCode("DE", CountryCodeType.CODE_2_CHARS));
 
         // add first Verification in the past result first name 95 VP
         newAgent();
index 03df9a3c9ad228e21c8a74babf3be5b31bc74d9b..dd800cbb22a26e537585fa0a09b4b0392dcd0b88 100644 (file)
@@ -4,6 +4,7 @@ import static org.junit.Assert.*;
 
 import org.cacert.gigi.GigiApiException;
 import org.cacert.gigi.dbObjects.Assurance.AssuranceType;
+import org.cacert.gigi.dbObjects.CountryCode.CountryCodeType;
 import org.cacert.gigi.dbObjects.NamePart.NamePartType;
 import org.cacert.gigi.testUtils.ClientBusinessTest;
 import org.cacert.gigi.util.Notary;
@@ -19,13 +20,13 @@ public class TestAssureName extends ClientBusinessTest {
         Name n4 = new Name(u, new NamePart(NamePartType.SINGLE_NAME, "Testiaac"));
 
         assertEquals(0, n0.getAssurancePoints());
-        Notary.assure(u0, u, n0, u.getDoB(), 10, "test mgr", validVerificationDateString(), AssuranceType.FACE_TO_FACE);
+        Notary.assure(u0, u, n0, u.getDoB(), 10, "test mgr", validVerificationDateString(), AssuranceType.FACE_TO_FACE, CountryCode.getCountryCode("DE", CountryCodeType.CODE_2_CHARS));
         assertEquals(10, n0.getAssurancePoints());
-        Notary.assure(u0, u, n2, u.getDoB(), 10, "test mgr", validVerificationDateString(), AssuranceType.FACE_TO_FACE);
+        Notary.assure(u0, u, n2, u.getDoB(), 10, "test mgr", validVerificationDateString(), AssuranceType.FACE_TO_FACE, CountryCode.getCountryCode("DE", CountryCodeType.CODE_2_CHARS));
         assertEquals(10, n2.getAssurancePoints());
-        Notary.assure(u0, u, n3, u.getDoB(), 10, "test mgr", validVerificationDateString(), AssuranceType.FACE_TO_FACE);
+        Notary.assure(u0, u, n3, u.getDoB(), 10, "test mgr", validVerificationDateString(), AssuranceType.FACE_TO_FACE, CountryCode.getCountryCode("DE", CountryCodeType.CODE_2_CHARS));
         assertEquals(10, n3.getAssurancePoints());
-        Notary.assure(u0, u, n4, u.getDoB(), 10, "test mgr", validVerificationDateString(), AssuranceType.FACE_TO_FACE);
+        Notary.assure(u0, u, n4, u.getDoB(), 10, "test mgr", validVerificationDateString(), AssuranceType.FACE_TO_FACE, CountryCode.getCountryCode("DE", CountryCodeType.CODE_2_CHARS));
         assertEquals(10, n4.getAssurancePoints());
         assertEquals(10, u.getMaxAssurePoints());
     }
index 2e74670e8e9577c086384297fe3b325e8e825560..7112bd2d4e71494358614dd80e4a76f494816249 100644 (file)
@@ -29,7 +29,7 @@ public class TestPasswordResetExternal extends ClientTest {
         String cookie2 = login(u.getEmail(), TEST_PASSWORD);
         URLConnection uc = TestAssurance.buildupAssureFormConnection(cookie2, email, true);
         String avalue = RandomToken.generateToken(32);
-        uc.getOutputStream().write(("assuredName=" + this.u.getPreferredName().getId() + "&date=" + TestAssurance.validVerificationDateString() + "&location=testcase&certify=1&rules=1&assertion=1&points=10&passwordReset=1&passwordResetValue=" + URLEncoder.encode(avalue, "UTF-8")).getBytes("UTF-8"));
+        uc.getOutputStream().write(("assuredName=" + this.u.getPreferredName().getId() + "&date=" + TestAssurance.validVerificationDateString() + "&location=testcase&countryCode=DE&certify=1&rules=1&assertion=1&points=10&passwordReset=1&passwordResetValue=" + URLEncoder.encode(avalue, "UTF-8")).getBytes("UTF-8"));
         uc.getOutputStream().flush();
         String error = fetchStartErrorMessage(IOUtils.readURL(uc));
         assertNull(error);
index 136ca610e5b6af7fdff1aaabcd3d7e29266aea8d..84cd6dc44ae12bfd37890d931572a6bd8a81ce41 100644 (file)
@@ -93,13 +93,13 @@ public class TestAssurance extends ManagedTest {
 
     @Test
     public void testAssureForm() throws IOException {
-        executeSuccess("date=" + validVerificationDateString() + "&location=testcase&certify=1&rules=1&assertion=1&points=10");
+        executeSuccess("date=" + validVerificationDateString() + "&location=testcase&countryCode=DE&certify=1&rules=1&assertion=1&points=10");
     }
 
     @Test
     public void testAssureFormEmpty() throws IOException {
         URLConnection uc = buildupAssureFormConnection(true);
-        uc.getOutputStream().write(("date=" + validVerificationDateString() + "&location=testcase&rules=1&assertion=1&points=10").getBytes("UTF-8"));
+        uc.getOutputStream().write(("date=" + validVerificationDateString() + "&location=testcase&countryCode=DE&rules=1&assertion=1&points=10").getBytes("UTF-8"));
         uc.getOutputStream().flush();
         String data = IOUtils.readURL(uc);
         assertThat(data, hasError());
@@ -108,7 +108,7 @@ public class TestAssurance extends ManagedTest {
     @Test
     public void testAssureFormContanisData() throws IOException {
         URLConnection uc = buildupAssureFormConnection(true);
-        uc.getOutputStream().write(("assuredName=" + assureeName + "&date=" + validVerificationDateString() + "&location=testcase&rules=1&assertion=1&points=10").getBytes("UTF-8"));
+        uc.getOutputStream().write(("assuredName=" + assureeName + "&date=" + validVerificationDateString() + "&location=testcase&countryCode=DE&rules=1&assertion=1&points=10").getBytes("UTF-8"));
         uc.getOutputStream().flush();
         String data = IOUtils.readURL(uc);
         assertThat(data, containsString(validVerificationDateString()));
@@ -119,7 +119,7 @@ public class TestAssurance extends ManagedTest {
     public void testAssureFormNoCSRF() throws IOException {
         // override csrf
         HttpURLConnection uc = (HttpURLConnection) buildupAssureFormConnection(false);
-        uc.getOutputStream().write(("date=" + validVerificationDateString() + "&location=testcase&certify=1&rules=1&assertion=1&points=10").getBytes("UTF-8"));
+        uc.getOutputStream().write(("date=" + validVerificationDateString() + "&location=testcase&countryCode=DE&certify=1&rules=1&assertion=1&points=10").getBytes("UTF-8"));
         uc.getOutputStream().flush();
         assertEquals(500, uc.getResponseCode());
     }
@@ -128,7 +128,7 @@ public class TestAssurance extends ManagedTest {
     public void testAssureFormWrongCSRF() throws IOException {
         // override csrf
         HttpURLConnection uc = (HttpURLConnection) buildupAssureFormConnection(false);
-        uc.getOutputStream().write(("date=" + validVerificationDateString() + "&location=testcase&certify=1&rules=1&assertion=1&points=10&csrf=aragc").getBytes("UTF-8"));
+        uc.getOutputStream().write(("date=" + validVerificationDateString() + "&location=testcase&countryCode=DE&certify=1&rules=1&assertion=1&points=10&csrf=aragc").getBytes("UTF-8"));
         uc.getOutputStream().flush();
         assertEquals(500, uc.getResponseCode());
     }
@@ -151,7 +151,7 @@ public class TestAssurance extends ManagedTest {
 
         assertNull(executeBasicWebInteraction(assureeCookie, MyDetails.PATH, newDob + "&action=updateDoB", 0));
 
-        uc.getOutputStream().write(("assuredName=" + assureeName + "&date=" + validVerificationDateString() + "&location=testcase&certify=1&rules=1&assertion=1&points=10").getBytes("UTF-8"));
+        uc.getOutputStream().write(("assuredName=" + assureeName + "&date=" + validVerificationDateString() + "&location=testcase&countryCode=DE&certify=1&rules=1&assertion=1&points=10").getBytes("UTF-8"));
         uc.getOutputStream().flush();
         String error = fetchStartErrorMessage(IOUtils.readURL(uc));
         if (succeed) {
@@ -166,7 +166,7 @@ public class TestAssurance extends ManagedTest {
     public void testAssureFormFuture() throws IOException {
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
         int year = Integer.parseInt(sdf.format(new Date(System.currentTimeMillis()))) + 2;
-        executeFails("date=" + year + "-01-01&location=testcase&certify=1&rules=1&assertion=1&points=10");
+        executeFails("date=" + year + "-01-01&location=testcase&countryCode=DE&certify=1&rules=1&assertion=1&points=10");
     }
 
     @Test
@@ -176,12 +176,12 @@ public class TestAssurance extends ManagedTest {
         c.setTimeInMillis(System.currentTimeMillis());
         c.add(Calendar.HOUR_OF_DAY, 12);
 
-        executeSuccess("date=" + sdf.format(new Date(c.getTimeInMillis())) + "&location=testcase&certify=1&rules=1&assertion=1&points=10");
+        executeSuccess("date=" + sdf.format(new Date(c.getTimeInMillis())) + "&location=testcase&countryCode=DE&certify=1&rules=1&assertion=1&points=10");
     }
 
     @Test
     public void testAssureFormPastInRange() throws IOException {
-        executeSuccess("date=" + validVerificationDateString() + "&location=testcase&certify=1&rules=1&assertion=1&points=10");
+        executeSuccess("date=" + validVerificationDateString() + "&location=testcase&countryCode=DE&certify=1&rules=1&assertion=1&points=10");
     }
 
     @Test
@@ -192,7 +192,7 @@ public class TestAssurance extends ManagedTest {
         c.add(Calendar.MONTH, -Notary.LIMIT_MAX_MONTHS_VERIFICATION);
         c.add(Calendar.DAY_OF_MONTH, 1);
 
-        executeSuccess("date=" + sdf.format(new Date(c.getTimeInMillis())) + "&location=testcase&certify=1&rules=1&assertion=1&points=10");
+        executeSuccess("date=" + sdf.format(new Date(c.getTimeInMillis())) + "&location=testcase&countryCode=DE&certify=1&rules=1&assertion=1&points=10");
     }
 
     @Test
@@ -202,32 +202,32 @@ public class TestAssurance extends ManagedTest {
         c.setTimeInMillis(System.currentTimeMillis());
         c.add(Calendar.MONTH, -Notary.LIMIT_MAX_MONTHS_VERIFICATION);
 
-        executeFails("date=" + sdf.format(new Date(c.getTimeInMillis())) + "&location=testcase&certify=1&rules=1&assertion=1&points=10");
+        executeFails("date=" + sdf.format(new Date(c.getTimeInMillis())) + "&location=testcase&countryCode=DE&certify=1&rules=1&assertion=1&points=10");
     }
 
     @Test
     public void testAssureFormNoLoc() throws IOException {
-        executeFails("date=" + validVerificationDateString() + "&location=a&certify=1&rules=1&assertion=1&points=10");
-        executeFails("date=" + validVerificationDateString() + "&location=&certify=1&rules=1&assertion=1&points=10");
+        executeFails("date=" + validVerificationDateString() + "&location=a&countryCode=DE&certify=1&rules=1&assertion=1&points=10");
+        executeFails("date=" + validVerificationDateString() + "&location=&countryCode=DE&certify=1&rules=1&assertion=1&points=10");
     }
 
     @Test
     public void testAssureFormInvalDate() throws IOException {
-        executeFails("date=20000101&location=testcase&certify=1&rules=1&assertion=1&points=10");
-        executeFails("date=&location=testcase&certify=1&rules=1&assertion=1&points=10");
+        executeFails("date=20000101&location=testcase&countryCode=DE&certify=1&rules=1&assertion=1&points=10");
+        executeFails("date=&location=testcase&countryCode=DE&certify=1&rules=1&assertion=1&points=10");
     }
 
     @Test
     public void testAssureFormBoxes() throws IOException {
-        executeFails("date=" + validVerificationDateString() + "&location=testcase&certify=0&rules=1&assertion=1&points=10");
-        executeFails("date=" + validVerificationDateString() + "&location=testcase&certify=1&rules=&assertion=1&points=10");
-        executeFails("date=" + validVerificationDateString() + "&location=testcase&certify=1&rules=1&assertion=z&points=10");
+        executeFails("date=" + validVerificationDateString() + "&location=testcase&countryCode=DE&certify=0&rules=1&assertion=1&points=10");
+        executeFails("date=" + validVerificationDateString() + "&location=testcase&countryCode=DE&certify=1&rules=&assertion=1&points=10");
+        executeFails("date=" + validVerificationDateString() + "&location=testcase&countryCode=DE&certify=1&rules=1&assertion=z&points=10");
     }
 
     @Test
     public void testAssureListingValid() throws IOException {
         String uniqueLoc = createUniqueName();
-        execute("date=" + validVerificationDateString() + "&location=" + uniqueLoc + "&certify=1&rules=1&assertion=1&points=10");
+        execute("date=" + validVerificationDateString() + "&location=" + uniqueLoc + "&countryCode=DE&certify=1&rules=1&assertion=1&points=10");
 
         String cookie = login(assureeM, TEST_PASSWORD);
         URLConnection url = get(cookie, Points.PATH);
@@ -239,7 +239,7 @@ public class TestAssurance extends ManagedTest {
     @Test
     public void testAssurerListingValid() throws IOException {
         String uniqueLoc = createUniqueName();
-        executeSuccess("date=" + validVerificationDateString() + "&location=" + uniqueLoc + "&certify=1&rules=1&assertion=1&points=10");
+        executeSuccess("date=" + validVerificationDateString() + "&location=" + uniqueLoc + "&countryCode=DE&certify=1&rules=1&assertion=1&points=10");
         String cookie = login(assurerM, TEST_PASSWORD);
         URLConnection url = get(cookie, Points.PATH);
         String resp = IOUtils.readURL(url);
@@ -304,7 +304,7 @@ public class TestAssurance extends ManagedTest {
 
         // enter second entry
         String uniqueLoc = createUniqueName();
-        executeSuccess("date=" + validVerificationDateString() + "&location=" + uniqueLoc + "&certify=1&rules=1&assertion=1&points=10");
+        executeSuccess("date=" + validVerificationDateString() + "&location=" + uniqueLoc + "&countryCode=DE&certify=1&rules=1&assertion=1&points=10");
 
         // enter third entry on the same day
         URLConnection uc = get(cookie, AssurePage.PATH);
index 37451573c28c32ea51503f100d7432257b5e4a9d..c0426b9b2443767cc39022a030b46fea1a4d2030 100644 (file)
@@ -8,6 +8,8 @@ import java.util.Date;
 import org.cacert.gigi.GigiApiException;
 import org.cacert.gigi.database.GigiPreparedStatement;
 import org.cacert.gigi.dbObjects.Assurance.AssuranceType;
+import org.cacert.gigi.dbObjects.CountryCode;
+import org.cacert.gigi.dbObjects.CountryCode.CountryCodeType;
 import org.cacert.gigi.dbObjects.ObjectCache;
 import org.cacert.gigi.dbObjects.User;
 import org.cacert.gigi.output.DateSelector;
@@ -16,8 +18,10 @@ import org.junit.Test;
 
 public class TestNotary extends BusinessTest {
 
-    // These tests create a lot of users and therefore require resetting of the
-    // registering-rate-limit.
+    public final CountryCode DE = CountryCode.getCountryCode("DE", CountryCodeType.CODE_2_CHARS);
+
+    public TestNotary() throws GigiApiException {}
+
     @Test
     public void testNormalAssurance() throws SQLException, GigiApiException {
         User[] users = new User[30];
@@ -31,7 +35,7 @@ public class TestNotary extends BusinessTest {
         };
 
         try {
-            Notary.assure(assurer, users[0], users[0].getPreferredName(), users[0].getDoB(), -1, "test-notary", validVerificationDateString(), AssuranceType.FACE_TO_FACE);
+            Notary.assure(assurer, users[0], users[0].getPreferredName(), users[0].getDoB(), -1, "test-notary", validVerificationDateString(), AssuranceType.FACE_TO_FACE, DE);
             fail("This shouldn't have passed");
         } catch (GigiApiException e) {
             // expected
@@ -40,7 +44,7 @@ public class TestNotary extends BusinessTest {
             assertEquals(result[i], assurer.getMaxAssurePoints());
 
             assuranceFail(assurer, users[i], result[i] + 1, "test-notary", validVerificationDateString());
-            Notary.assure(assurer, users[i], users[i].getPreferredName(), users[i].getDoB(), result[i], "test-notary", validVerificationDateString(), AssuranceType.FACE_TO_FACE);
+            Notary.assure(assurer, users[i], users[i].getPreferredName(), users[i].getDoB(), result[i], "test-notary", validVerificationDateString(), AssuranceType.FACE_TO_FACE, DE);
             assuranceFail(assurer, users[i], result[i], "test-notary", validVerificationDateString());
         }
 
@@ -52,7 +56,7 @@ public class TestNotary extends BusinessTest {
 
     private void assuranceFail(User assurer, User user, int i, String location, String date) throws SQLException {
         try {
-            Notary.assure(assurer, user, user.getPreferredName(), user.getDoB(), i, location, date, AssuranceType.FACE_TO_FACE);
+            Notary.assure(assurer, user, user.getPreferredName(), user.getDoB(), i, location, date, AssuranceType.FACE_TO_FACE, DE);
             fail("This shouldn't have passed");
         } catch (GigiApiException e) {
             // expected
@@ -77,7 +81,7 @@ public class TestNotary extends BusinessTest {
             assuranceFail(assurer, users[i], -1, "test-notary", validVerificationDateString());
             assuranceFail(assurer, users[i], 11, "test-notary", validVerificationDateString());
             if (User.POJAM_ENABLED) {
-                Notary.assure(assurer, users[i], users[i].getPreferredName(), users[i].getDoB(), 10, "test-notary", validVerificationDateString(), AssuranceType.FACE_TO_FACE);
+                Notary.assure(assurer, users[i], users[i].getPreferredName(), users[i].getDoB(), 10, "test-notary", validVerificationDateString(), AssuranceType.FACE_TO_FACE, DE);
             }
             assuranceFail(assurer, users[i], 10, "test-notary", validVerificationDateString());
         }
@@ -113,7 +117,7 @@ public class TestNotary extends BusinessTest {
         assuranceFail(assuree, assuranceUser, 10, "notary-junit-test", validVerificationDateString());
 
         // valid
-        Notary.assure(assuranceUser, assuree, assuree.getPreferredName(), assuree.getDoB(), 10, "notary-junit-test", validVerificationDateString(), AssuranceType.FACE_TO_FACE);
+        Notary.assure(assuranceUser, assuree, assuree.getPreferredName(), assuree.getDoB(), 10, "notary-junit-test", validVerificationDateString(), AssuranceType.FACE_TO_FACE, DE);
 
         // verify double
         assuranceFail(assuranceUser, assuree, 10, "notary-junit-test", validVerificationDateString());
index 0cf8e12d6055f342d0f81582cdad8922b4470ebb..f599fcd6b2835cc44bb3f7a039c25bc0c40a7535 100644 (file)
@@ -34,6 +34,8 @@ import org.cacert.gigi.dbObjects.CATS.CATSType;
 import org.cacert.gigi.dbObjects.Certificate;
 import org.cacert.gigi.dbObjects.Certificate.CertificateStatus;
 import org.cacert.gigi.dbObjects.CertificateOwner;
+import org.cacert.gigi.dbObjects.CountryCode;
+import org.cacert.gigi.dbObjects.CountryCode.CountryCodeType;
 import org.cacert.gigi.dbObjects.Digest;
 import org.cacert.gigi.dbObjects.Domain;
 import org.cacert.gigi.dbObjects.DomainPingType;
@@ -313,7 +315,7 @@ public class Manager extends Page {
                     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);
+                    Notary.assure(getAssurer(agentNumber), byEmail, byEmail.getPreferredName(), byEmail.getDoB(), currentVP, "Testmanager Verify up code", "2014-11-06", AssuranceType.FACE_TO_FACE, CountryCode.getCountryCode("DE", CountryCodeType.CODE_2_CHARS));
                     agentNumber += 1;
                     vp -= currentVP;
                 }
@@ -330,7 +332,7 @@ public class Manager extends Page {
             try {
                 for (int i = 0; i < 25; i++) {
                     User a = getAssurer(i);
-                    Notary.assure(byEmail, a, a.getNames()[0], 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, CountryCode.getCountryCode("DE", CountryCodeType.CODE_2_CHARS));
                 }
             } catch (GigiApiException e) {
                 throw new Error(e);