]> WPIA git - gigi.git/commitdiff
ADD: Contet to SE Page
authorJanis Streib <janis@dogcraft.de>
Tue, 13 Jan 2015 17:23:21 +0000 (18:23 +0100)
committerJanis Streib <janis@dogcraft.de>
Tue, 13 Jan 2015 17:48:44 +0000 (18:48 +0100)
src/org/cacert/gigi/pages/admin/support/SupportUserDetailsForm.java
src/org/cacert/gigi/pages/admin/support/SupportUserDetailsForm.templ
src/org/cacert/gigi/pages/admin/support/SupportUserDetailsPage.java
src/org/cacert/gigi/pages/admin/support/SupportUserDetailsPage.templ [new file with mode: 0644]

index ee34a6b2e0620c9d2b115b67e1bc18ddb2fb60eb..82cc2745702d6601ed055aa152353b8c25b0480e 100644 (file)
@@ -6,13 +6,25 @@ import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 
 import org.cacert.gigi.GigiApiException;
 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.localisation.Language;
+import org.cacert.gigi.output.DateSelector;
 import org.cacert.gigi.output.template.Form;
 import org.cacert.gigi.output.template.Form;
+import org.cacert.gigi.output.template.Template;
 
 public class SupportUserDetailsForm extends Form {
 
 
 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);
         super(hsr);
+        this.user = user;
     }
 
     @Override
     }
 
     @Override
@@ -21,6 +33,22 @@ public class SupportUserDetailsForm extends Form {
     }
 
     @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);
+    }
 
 }
 
 }
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..5d35a792b1dca3ca6f73299ef9c545c03c4609b2 100644 (file)
@@ -0,0 +1,119 @@
+<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
index 9b135e749583bdd28fabe9350b6e8963a10b8d01..46b4aca292f0455631a29bf0d4320efc212b7997 100644 (file)
@@ -1,10 +1,21 @@
 package org.cacert.gigi.pages.admin.support;
 
 import java.io.IOException;
 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 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 {
 import org.cacert.gigi.pages.Page;
 
 public class SupportUserDetailsPage extends Page {
@@ -16,6 +27,70 @@ public class SupportUserDetailsPage extends Page {
     }
 
     @Override
     }
 
     @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);
+    }
 }
 }
diff --git a/src/org/cacert/gigi/pages/admin/support/SupportUserDetailsPage.templ b/src/org/cacert/gigi/pages/admin/support/SupportUserDetailsPage.templ
new file mode 100644 (file)
index 0000000..5c0ef84
--- /dev/null
@@ -0,0 +1,41 @@
+<?=$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