import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.Signature;
+import java.text.SimpleDateFormat;
import java.util.Base64;
import java.util.Calendar;
import java.util.Date;
public class Manager extends Page {
+ public static String validVerificationDateString() {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+ Calendar c = Calendar.getInstance();
+ c.setTimeInMillis(System.currentTimeMillis());
+ c.add(Calendar.MONTH, -Notary.LIMIT_MAX_MONTHS_VERIFICATION + 1);
+ return sdf.format(new Date(c.getTimeInMillis()));
+ }
+
public static Country getRandomCountry() {
List<Country> cc = Country.getCountries();
int rnd = new Random().nextInt(cc.size());
if ( !u.isInGroup(Group.SUPPORTER)) {
try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `user_groups` SET `user`=?, `permission`=?::`userGroup`, `grantedby`=?")) {
ps.setInt(1, u.getId());
- ps.setString(2, Group.SUPPORTER.getDatabaseName());
+ ps.setString(2, Group.SUPPORTER.getDBName());
ps.setInt(3, u.getId());
ps.execute();
}
resp.getWriter().println("User not found.");
return;
}
- if (req.getParameter("addpriv") != null) {
- try {
+ try {
+ if (req.getParameter("addpriv") != null) {
u.grantGroup(getSupporter(), Group.getByString(req.getParameter("priv")));
- } catch (GigiApiException e) {
- throw new Error(e);
+ resp.getWriter().println("Privilege granted");
+ } else {
+ u.revokeGroup(getSupporter(), Group.getByString(req.getParameter("priv")));
+ resp.getWriter().println("Privilege revoked");
}
- resp.getWriter().println("Privilege granted");
- } else {
- u.revokeGroup(u, Group.getByString(req.getParameter("priv")));
- resp.getWriter().println("Privilege revoked");
+ } catch (GigiApiException e) {
+ throw new Error(e);
}
} else if (req.getParameter("fetch") != null) {
String mail = req.getParameter("femail");
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, getRandomCountry());
+ Notary.assure(getAssurer(agentNumber), byEmail, byEmail.getPreferredName(), byEmail.getDoB(), currentVP, "Testmanager Verify up code", validVerificationDateString(), AssuranceType.FACE_TO_FACE, getRandomCountry());
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, getRandomCountry());
+ Notary.assure(byEmail, a, a.getNames()[0], a.getDoB(), 10, "Testmanager exp up code", validVerificationDateString(), AssuranceType.FACE_TO_FACE, getRandomCountry());
}
} catch (GigiApiException e) {
throw new Error(e);
vars.put("reverificationDays", TimeConditions.getInstance().getVerificationLimitDays());
vars.put("verificationFreshMonths", TimeConditions.getInstance().getVerificationMonths());
vars.put("verificationMaxAgeMonths", TimeConditions.getInstance().getVerificationMaxAgeMonths());
+ vars.put("emailPingMonths", TimeConditions.getInstance().getEmailPingMonths());
form.output(resp.getWriter(), getLanguage(req), vars);
}