<?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>
<x>710</x>
<y>1090</y>
<w>390</w>
- <h>180</h>
+ <h>200</h>
</coordinates>
<panel_attributes>Assurance
--
-expire: timestamp
-sponsor: User (??????????)
-deleted: timestamp
+-country: varchar(2)
</panel_attributes>
<additional_attributes/>
</element>
<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></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>
}
- 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;
"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")
);
"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` (
--- /dev/null
+ALTER TABLE "notary" ADD COLUMN "country" varchar(2) NULL;
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;
this.method = method;
this.points = points;
this.date = date;
+ this.country = country;
}
return date;
}
+ public CountryCode getCountry() {
+ return country;
+ }
}
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;
}
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() {
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;
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;
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);
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");
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 {
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!"));
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());
<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>
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;
* @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()) {
} 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.");
}
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()));
}
}
}
- 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);
}
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) {
// 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.");
}
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);
}
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;
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"));
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;
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));
}
}
}
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) {
// 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();
// 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();
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;
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());
}
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);
@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());
@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()));
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());
}
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());
}
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) {
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
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
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
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);
@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);
// 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);
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;
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];
};
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
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());
}
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
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());
}
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());
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;
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;
}
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);