import javax.servlet.http.HttpServletRequest;
import org.cacert.gigi.GigiApiException;
+import org.cacert.gigi.dbObjects.User;
import org.cacert.gigi.localisation.Language;
+import org.cacert.gigi.output.DateSelector;
import org.cacert.gigi.output.template.Form;
+import org.cacert.gigi.output.template.Template;
public class SupportUserDetailsForm extends Form {
- public SupportUserDetailsForm(HttpServletRequest hsr) {
+ private static Template t;
+
+ private User user;
+
+ static {
+ t = new Template(FindDomainForm.class.getResource("SupportUserDetailsForm.templ"));
+ }
+
+ public SupportUserDetailsForm(HttpServletRequest hsr, User user) {
super(hsr);
+ this.user = user;
}
@Override
}
@Override
- protected void outputContent(PrintWriter out, Language l, Map<String, Object> vars) {}
+ protected void outputContent(PrintWriter out, Language l, Map<String, Object> vars) {
+ vars.put("mail", user.getEmail());
+ vars.put("fname", user.getFname());
+ vars.put("mname", user.getMname());
+ vars.put("lname", user.getLname());
+ vars.put("suffix", user.getSuffix());
+ vars.put("assurer", user.canAssure());
+ vars.put("dob", new DateSelector("dobd", "dobm", "doby", user.getDob()));
+ vars.put("blockedassurer", false); // TODO Fill all following "false"
+ vars.put("locked", false);
+ vars.put("codesign", false);
+ vars.put("orgassurer", false);
+ vars.put("ttpadmin", false);
+ vars.put("assurancepoints", user.getAssurancePoints());
+ vars.put("id", user.getId());
+ t.output(out, l, vars);
+ }
}
+<table class="wrapper dataTable centertext">
+ <tbody><tr>
+ <th colspan="2"><?=$mail?>'s Account Details</th>
+ </tr>
+ <tr>
+ <td>Email:</td>
+ <td><?=$mail?></td>
+ </tr>
+ <tr>
+ <td><?=_First Name?>:</td>
+ <td>
+ <input type="text" value="<?=$fname?>" name="fname">
+ </td>
+ </tr>
+ <tr>
+ <td><?=_Middle Name?>:</td>
+ <td><input type="text" value="<?=$mname?>" name="mname"></td>
+ </tr>
+ <tr>
+ <td><?=_Last Name?>:</td>
+ <td>
+ <input type="text" value="<?=$lname?>" name="lname">
+ </td>
+ </tr>
+ <tr>
+ <td><?=_Suffix?>:</td>
+ <td><input type="text" value="<?=$suffix?>" name="suffix"></td>
+ </tr>
+ <tr>
+ <td><?=_Date of Birth?>:</td>
+ <td>
+ <?=$dob?>
+ </td>
+ </tr>
+ <tr>
+ <td><?=_Trainings?>:</td>
+ <td><a href="./<?=$id?>/trainings"><?=_Show?></a></td>
+ </tr>
+ <tr>
+ <td><?=_Is Assurer?>:</td>
+ <td>
+ <? if($assurer) { ?>
+ <?=_Yes?>
+ <? } else { ?>
+ <?=_No?>
+ <? } ?>
+ </td>
+ </tr>
+ <tr>
+ <td><?=_Blocked Assurer?>:</td>
+ <td>
+ <? if($blockedassurer) { ?>
+ <?=_Yes?>
+ <? } else { ?>
+ <?=_No?>
+ <? } ?>
+ </td>
+ </tr>
+ <tr>
+ <td><?=_Account Locking?>:</td>
+ <td>
+ <? if($locked) { ?>
+ <?=_Yes?>
+ <? } else { ?>
+ <?=_No?>
+ <? } ?>
+ </td>
+ </tr>
+ <tr>
+ <td><?=_Code Signing?>:</td>
+ <td><? if($codesign) { ?>
+ <?=_Yes?>
+ <? } else { ?>
+ <?=_No?>
+ <? } ?>
+ </td>
+ </tr>
+ <tr>
+ <td><?=_Org Assurer?>:</td>
+ <td>
+ <? if($orgassurer) { ?>
+ <?=_Yes?>
+ <? } else { ?>
+ <?=_No?>
+ <? } ?>
+</td>
+ </tr>
+ <tr>
+ <td><?=_TTP Admin?>:</td>
+ <td>
+<? if($ttpadmin) { ?>
+ <?=_Yes?>
+ <? } else { ?>
+ <?=_No?>
+ <? } ?>
+</td>
+ </tr>
+ <tr>
+ <td><?=_Change Password?>:</td>
+ <td><?=_Change Password?></td>
+ </tr>
+ <tr>
+ <td><?=_Delete Account?>:</td>
+ <td><?=_Delete Account?></td>
+ </tr>
+ <tr>
+ <td><?=_Show Lost Password Details?></td>
+ </tr>
+ <tr>
+ <td><?=_Assurance Points?>:</td>
+ <td><?=$assurancepoints?></td>
+ </tr>
+ <tr>
+ <td colspan="2"><a href="./<?=$id?>/history"><?=_Show account history?></a></td>
+ </tr>
+ <tr><td colspan="2"><input type="submit" value="<?=_Update?>"/></td></tr>
+ </tbody>
+</table>
+<br/>
\ No newline at end of file
package org.cacert.gigi.pages.admin.support;
import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.cacert.gigi.dbObjects.Certificate;
+import org.cacert.gigi.dbObjects.CertificateProfile;
+import org.cacert.gigi.dbObjects.EmailAddress;
+import org.cacert.gigi.dbObjects.User;
+import org.cacert.gigi.localisation.Language;
+import org.cacert.gigi.output.DateSelector;
+import org.cacert.gigi.output.template.IterableDataset;
import org.cacert.gigi.pages.Page;
public class SupportUserDetailsPage extends Page {
}
@Override
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {}
+ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
+ int id;
+ String[] idP = req.getPathInfo().split("/");
+ id = Integer.parseInt(idP[idP.length - 1]);
+ final User user = User.getById(id);
+ SupportUserDetailsForm f = new SupportUserDetailsForm(req, user);
+ HashMap<String, Object> vars = new HashMap<String, Object>();
+ vars.put("details", f);
+ final EmailAddress[] addrs = user.getEmails();
+ vars.put("emails", new IterableDataset() {
+ int i = 0;
+
+ @Override
+ public boolean next(Language l, Map<String, Object> vars) {
+ String address = addrs[i].getAddress();
+ if ( !address.equals(user.getEmail())) {
+ vars.put("secmail", address);
+ }
+ i++;
+ return i != addrs.length - 1;
+ }
+ });
+ final Certificate[] certs = user.getCertificates(true);
+ final CertificateProfile[] profiles = CertificateProfile.getAll();
+ vars.put("types", new IterableDataset() {
+
+ int typeIndex = 0;
+
+ @Override
+ public boolean next(Language l, Map<String, Object> vars) {
+ if (typeIndex > profiles.length - 1) {
+ return false;
+ }
+ int valid = 0;
+ int total = 0;
+ long lastExpire = Long.MIN_VALUE;
+ for (int i = 0; i < certs.length; i++) {
+ try {
+ if (certs[i].getProfile().getId() != profiles[typeIndex].getId()) {
+ continue;
+ }
+ total++;
+ certs[i].cert().checkValidity();
+ lastExpire = Math.max(lastExpire, certs[i].cert().getNotAfter().getTime());
+ valid++;
+ } catch (GeneralSecurityException | IOException e) {
+ continue;
+ }
+ }
+ vars.put("total", total);
+ vars.put("profile", profiles[typeIndex].getVisibleName());
+ vars.put("valid", valid);
+ vars.put("exp", total - valid);
+ vars.put("rev", "TODO");
+ if (lastExpire == Long.MIN_VALUE) {
+ vars.put("lastdate", "-");
+ } else {
+ vars.put("lastdate", DateSelector.getDateFormat().format(new Date(lastExpire)));
+ }
+ typeIndex++;
+ return true;
+ }
+ });
+ getDefaultTemplate().output(resp.getWriter(), getLanguage(req), vars);
+ }
}
--- /dev/null
+<?=$details?>
+<table class="wrapper dataTable centertext">
+ <tbody><tr>
+ <th><?=_Alternate Verified Email Addresses?></th>
+ </tr>
+ <? foreach($emails) {?>
+ <tr>
+ <td><?=$secmail?></td>
+ </tr>
+ <? } ?>
+ </tbody>
+</table>
+<br/>
+<table class="wrapper dataTable">
+ <tbody><tr>
+ <th colspan="6"><?=_Certificates?></td>
+ </tr>
+ <tr>
+ <th><?=_Cert Type?></th>
+ <th><?=_Total?></th>
+ <th><?=_Valid?></th>
+ <th><?=_Expired?></th>
+ <th><?=_Revoked?></th>
+ <th><?=_Latest Expire?></th>
+ </tr>
+ <? foreach($types) { ?>
+ <tr>
+ <td><?=$profile?></th>
+ <td><?=$total?></td>
+ <td><?=$valid?></td>
+ <td><?=$exp?></td>
+ <td><?=$rev?></td>
+ <td><?=$lastdate?></td>
+ </tr>
+ <? } ?>
+ <tr>
+ <td colspan="6" class="title">
+ <input value="revoke certificates" type="submit">
+ </td>
+ </tr>
+ </tbody></table>
\ No newline at end of file