+++ /dev/null
-package club.wpia.gigi.output;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import club.wpia.gigi.dbObjects.Group;
-import club.wpia.gigi.localisation.Language;
-import club.wpia.gigi.output.template.IterableDataset;
-
-public class GroupIterator implements IterableDataset {
-
- private final boolean asSupport;
-
- private final Iterator<Group> i;
-
- public GroupIterator(Iterator<Group> i, boolean asSupport) {
- this.asSupport = asSupport;
- this.i = i;
- }
-
- private int j = 0;
-
- @Override
- public boolean next(Language l, Map<String, Object> vars) {
- while (i.hasNext()) {
- Group g = i.next();
- if (g.isManagedBySupport() == asSupport) {
- vars.put("group_concat", (j > 0 ? ", " : ""));
- vars.put("group", g.getName());
- j++;
- return true;
- }
- }
-
- return false;
- }
-}
--- /dev/null
+package club.wpia.gigi.output;
+
+import java.io.PrintWriter;
+import java.util.Map;
+
+import club.wpia.gigi.dbObjects.Group;
+import club.wpia.gigi.localisation.Language;
+import club.wpia.gigi.output.template.Outputable;
+
+public class GroupList implements Outputable {
+
+ private final Iterable<Group> groups;
+
+ private final boolean supportGroups;
+
+ public GroupList(Iterable<Group> groups, boolean supportGroups) {
+ this.groups = groups;
+ this.supportGroups = supportGroups;
+ }
+
+ @Override
+ public void output(PrintWriter out, Language l, Map<String, Object> vars) {
+ boolean fst = true;
+ for (Group g : groups) {
+ if (g.isManagedBySupport() != supportGroups) {
+ continue;
+ }
+ if ( !fst) {
+ out.write(", ");
+ } else {
+ fst = false;
+ }
+ g.getName().output(out, l, vars);
+ }
+ if (fst) {
+ out.println(l.getTranslation("none"));
+ }
+ }
+
+}
package club.wpia.gigi.pages;
import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import club.wpia.gigi.dbObjects.Certificate;
+import club.wpia.gigi.dbObjects.Domain;
+import club.wpia.gigi.dbObjects.EmailAddress;
+import club.wpia.gigi.dbObjects.Group;
+import club.wpia.gigi.dbObjects.Organisation;
+import club.wpia.gigi.dbObjects.User;
+import club.wpia.gigi.localisation.Language;
+import club.wpia.gigi.output.GroupList;
+import club.wpia.gigi.output.template.IterableDataset;
import club.wpia.gigi.output.template.Template;
public class MainPage extends Page {
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
Map<String, Object> vars = getDefaultVars(req);
if (LoginPage.getUser(req) != null) {
+ User u = LoginPage.getUser(req);
+ vars.put("username", u.getPreferredName());
+ final Set<Group> gr = u.getGroups();
+ vars.put("support-groups", new GroupList(gr, true));
+ vars.put("groups", new GroupList(gr, false));
+ vars.put("ra-agent", u.canVerify());
+ vars.put("vp", u.getVerificationPoints());
+ vars.put("xp", u.getExperiencePoints());
+
+ Certificate[] c = u.getCertificates(false);
+ vars.put("c-no", c.length);
+
+ final EmailAddress[] emails = u.getEmails();
+ IterableDataset ds = new IterableDataset() {
+
+ private int point = 0;
+
+ @Override
+ public boolean next(Language l, Map<String, Object> vars) {
+ if (point >= emails.length) {
+ return false;
+ }
+ EmailAddress emailAddress = emails[point];
+ vars.put("verification", l.getTranslation(emailAddress.isVerified() ? "Verified" : "Unverified"));
+ vars.put("last_verification", emailAddress.getLastPing(true));
+ vars.put("address", emailAddress.getAddress());
+ point++;
+ return true;
+ }
+ };
+ vars.put("emails", ds);
+
+ final Domain[] doms = u.getDomains();
+ IterableDataset dts = new IterableDataset() {
+
+ private int point = 0;
+
+ @Override
+ public boolean next(Language l, Map<String, Object> vars) {
+ if (point >= doms.length) {
+ return false;
+ }
+ Domain domain = doms[point];
+ vars.put("domain", domain.getSuffix());
+ vars.put("status", l.getTranslation(domain.isVerified() ? "Verified" : "Unverified"));
+ point++;
+ return true;
+ }
+ };
+ vars.put("domains", dts);
+ vars.put("nodomains", doms.length == 0);
+
+ final List<Organisation> o = u.getOrganisations();
+ vars.put("orgas", new IterableDataset() {
+
+ Iterator<Organisation> it = o.iterator();
+
+ @Override
+ public boolean next(Language l, Map<String, Object> vars) {
+ if ( !it.hasNext()) {
+ return false;
+ }
+ Organisation o = it.next();
+ vars.put("orgName", o.getName());
+ vars.put("orgID", o.getId());
+ return true;
+ }
+ });
+ vars.put("hasorgs", !o.isEmpty());
getDefaultTemplate().output(resp.getWriter(), getLanguage(req), vars);
+
} else {
notLog.output(resp.getWriter(), getLanguage(req), vars);
}
-<p><?=_Welcome to your account section of the website. Below is a description of the different sections and what they're for.?></p>
-<H4><?=_ET?></H4>
-<p><?=_If you would like to view news items or change languages you can click the logout or go home links. Go home doesn't log you out of the system, just returns you to the front of the website. Logout logs you out of the system.?></p>
-<H4><?=_My Details?></H4>
-<p><?=_In this section you will be able to edit your personal information (if you haven't been verified), update your pass phrase, and lost pass phrase questions. You will also be able to set your location for the Web of Trust, it also effects the email announcement settings which among other things can be set to notify you if you're within 200km of a planned verification event. You'll also be able to set additional contact information when you become fully trusted, so others can contact you to meet up outside official events.?></p>
-<h4><?=_Email Accounts and Client Certificates?></h4>
-<p><?=_The email account section is for adding/updating/removing email accounts which can be used to issue client certificates against. The client certificate section steps you through generating a certificate signing request for one or more emails you've registered in the email account section.?></p>
-<h4><?=_Domains and Server Certificates.?></h4>
-<p><?=_Before you can start issuing certificates for your website, irc server, smtp server, pop3, imap etc you will need to add domains to your account under the domain menu. You can also remove domains from here as well. Once you've added a domain you are free then to go into the Server Certificate section and start pasting CSR into the website and have the website return you a valid certificate for up to 2 years if you have 50 trust points, or 6 months for no trust points.?></p>
-<h4><?=_Org Client and Server Certificates?></h4>
-<p><?=_Once you have verified your company you will see these menu options. They allow you to issue as many certificates as you like without proving individual email accounts as you like, further more you are able to get your company details on the certificate.?></p>
-<h4><?=_ET Web of Trust?></h4>
-<p><?=_The Web of Trust system ET uses is similar to that many involved with GPG/PGP use, they hold face to face meetings to verify each others photo identities match their GPG/PGP key information. ET differs however in that we have modified things to work within the PKI framework, for you to gain trust in the system you must first locate someone already trusted. The trust person depending how many people they've trusted or meet before will determine how many points they can issue to you. Once you've met up you can show your ID and you will need to fill out a verification form which the person verifying your details must retain for verification reasons.?></p>
+<h3><?=_Welcome back, ${username}!?></h3>
+<h4><?=_Subscriber information?></h4>
+<div class="well">
+<? if($ra-agent) { ?><p><?=_You are an RA Agent.?></p><? } ?>
+<p><?=_Assigned support permissions?>: <?=$support-groups?></p>
+<p><?=_Assigned user-managed permissions?>: <?=$groups?> (<?=_!'<a href="/account/details">'more!'</a>'?>)</p>
+<p><?=_${vp} Verification Points and ${xp} Experience Points.?> (<?=_!'<a href="/wot/points">'more!'</a>'?>)</p>
+</div>
+
+<h4><?=_Certificate Information?></h4>
+<div class="well">
+<p><?=_${c-no} certificate(s) are issued for your account.?> (<?=_!'<a href="/account/certs">'more!'</a>'?>)</p>
+</div>
+
+<h4><?=_Subscribed domains and email addresses?></h4>
+<div class="panel panel-default">
+<div class="panel-heading">
+<?=_Your account lists the following email addresses?> (<?=_!'<a href="/account/mails">'more!'</a>'?>):
+</div>
+<table class="table">
+ <thead>
+ <tr>
+ <th><?=_Address?></th>
+ <th><?=_Status?></th>
+ <th><?=_Last successful verification?></th>
+ </tr>
+ </thead>
+ <tbody>
+ <? foreach($emails) {?>
+ <tr>
+ <td><?=$address?></td>
+ <td><?=$verification?></td>
+ <td><? if($last_verification) { ?><?=$last_verification?><? } else { ?><?=_N/A?><? } ?></td>
+ </tr>
+ <? } ?>
+ </tbody>
+</table>
+</div>
+
+<div class="panel panel-default">
+<div class="panel-heading">
+<?=_Your account lists the following domains?> (<?=_!'<a href="/account/domains">'more!'</a>'?>):
+</div>
+<? if($nodomains) { ?>
+<div class="panel-body">
+<?=_Currently no domains are registered for your account.?>
+</div>
+<? } else { ?>
+<table class="table">
+ <thead>
+ <tr>
+ <th><?=_Domain?></th>
+ <th><?=_Status?></th>
+ </tr>
+ </thead>
+ <tbody>
+ <? foreach($domains) { ?>
+ <tr>
+ <td><?=$domain?></td>
+ <td><?=$status?></td>
+ </tr>
+ <? } ?>
+</tbody></table>
+<? } ?>
+</div>
+
+<? if($hasorgs) { ?>
+<h4><?=_Organisations?></h4>
+<div class="well">
+ <p><?=_You are listed as administrator for these organisations?>:</p>
+ <ul>
+ <? foreach($orgas) { ?>
+ <li><?=$orgName?></li>
+ <? } ?>
+ </ul>
+ <p><?=_!'<a href="/account/details">'change to organisation administrator context!'</a>'?></p>
+</div>
+<? } ?>
+
import club.wpia.gigi.output.ArrayIterable;
import club.wpia.gigi.output.CountrySelector;
import club.wpia.gigi.output.DateSelector;
-import club.wpia.gigi.output.GroupIterator;
+import club.wpia.gigi.output.GroupList;
import club.wpia.gigi.output.GroupSelector;
import club.wpia.gigi.output.NameInput;
import club.wpia.gigi.output.template.Form;
}
final Set<Group> gr = target.getGroups();
- vars.put("support-groups", new GroupIterator(gr.iterator(), true));
- vars.put("groups", new GroupIterator(gr.iterator(), false));
+ vars.put("support-groups", new GroupList(gr, true));
+ vars.put("groups", new GroupList(gr, false));
vars.put("groupSelector", selectedGroup);
roles.output(out, l, vars);
}
<div class="panel-heading"><?=_Permissions / Group Assignments?></div>
<div class="panel-body">
<h4><?=_Support Managed Permissions?>:</h4>
- <? foreach($support-groups) { ?><?=$group_concat?><?=$group?><? } ?>
+ <?=$support-groups?>
<h4><?=_User Managed Permissions?>:</h4>
- <? foreach($groups) { ?><?=$group_concat?><?=$group?><? } ?>
+ <?=$groups?>
<h4><?=_Set User Managed Permissions?>:</h4>
<?=$groupSelector?> <button class="btn btn-info" name="action" value="addGroup"><?=_Add Group?></button> <button class="btn btn-info" name="action" value="removeGroup"><?=_Remove Group?></button>
</div>
-<p><?=_${appName} offers two ways to create a certificate.?>
-<?=_One is to paste a certificate signing request (CSR) created from an existing or newly created private key.?> <?=_ If you do not know what a CSR is or how to create one take a look at the !(/wiki/CSR)FAQ!'</a>'.?>
+<p><?=_${appName} offers two ways to create a certificate.?>
+<?=_One is to paste a certificate signing request (CSR) created from an existing or newly created private key.?> <?=_If you do not know what a CSR is or how to create one take a look at the !(/wiki/CSR)FAQ!'</a>'.?>
<?=_As an alternative you can generate the private key inside your browser and export it once the certificate has been issued.?></p>
<form method="post">
<table class="table">
<div class="panel panel-info panel-activatable">
<div class="panel-heading"><input type="checkbox" name="HTTPType" value="y"<?=$!http?>> <?=_Verify by reading HTTP-content?></div>
<div class="panel-body">
- <?=_Please make the following content available under ?><pre class='string'>http://<span class='exampleDomain'>example.org</span>/<?=$httpPrefix?><?=$tokenName?>.txt</pre><br/>
+ <?=_Please make the following content available at?> <pre class='string'>http://<span class='exampleDomain'>example.org</span>/<?=$httpPrefix?><?=$tokenName?>.txt</pre><br/>
<pre><?=$tokenValue?></pre>
</div>
</div>
import club.wpia.gigi.localisation.Language;
import club.wpia.gigi.output.ArrayIterable;
import club.wpia.gigi.output.DateSelector;
-import club.wpia.gigi.output.GroupIterator;
+import club.wpia.gigi.output.GroupList;
import club.wpia.gigi.output.GroupSelector;
import club.wpia.gigi.output.template.Form;
import club.wpia.gigi.output.template.Template;
vars.put("verificationPoints", user.getVerificationPoints());
vars.put("exppoints", user.getExperiencePoints());
final Set<Group> gr = user.getGroups();
- vars.put("support-groups", new GroupIterator(gr.iterator(), true));
- vars.put("groups", new GroupIterator(gr.iterator(), false));
+ vars.put("support-groups", new GroupList(gr, true));
+ vars.put("groups", new GroupList(gr, false));
vars.put("groupSelector", value);
t.output(out, l, vars);
}
<tr>
<td><?=_Support Managed Groups?>:</td>
- <td><p><? foreach($support-groups) { ?><?=$group_concat?><?=$group?><? } ?></p>
+ <td><p><?=$support-groups?></p>
<p><?=$groupSelector?><input class="btn btn-info" type='submit' value='<?=_Add Group?>' name='addGroup'> <input class="btn btn-info" type='submit' value='<?=_Remove Group?>' name='removeGroup'></p>
</td>
</tr>
<tr>
<td><?=_User Managed Groups?>:</td>
- <td><p><? foreach($groups) { ?><?=$group_concat?><?=$group?><? } ?></p>
+ <td><p><?=$groups?></p>
</td>
</tr>
private static void killPreviousInstance(Properties mainProps) {
try {
String targetPort = mainProps.getProperty("http.port");
- String targetHost = mainProps.getProperty("name.www");
+ String targetHost = mainProps.getProperty("name.www", "www." + mainProps.getProperty("name.suffix"));
URL u = new URL("http://" + targetHost + ":" + targetPort + "/kill");
u.openStream();
} catch (IOException e) {