import org.cacert.gigi.pages.orga.CreateOrgPage;
import org.cacert.gigi.pages.orga.ViewOrgPage;
import org.cacert.gigi.pages.wot.AssurePage;
+import org.cacert.gigi.pages.wot.MyListingPage;
import org.cacert.gigi.pages.wot.MyPoints;
import org.cacert.gigi.pages.wot.RequestTTPPage;
import org.cacert.gigi.ping.PingerDaemon;
putPage(MailOverview.DEFAULT_PATH, new MailOverview("Email addresses"), "Certificates");
putPage(DomainOverview.PATH + "*", new DomainOverview("Domains"), "Certificates");
putPage(MyPoints.PATH, new MyPoints("My Points"), "Web of Trust");
+ putPage(MyListingPage.PATH, new MyListingPage(), "Web of Trust");
putPage(RequestTTPPage.PATH, new RequestTTPPage(), "Web of Trust");
putPage(TTPAdminPage.PATH + "/*", new TTPAdminPage(), "Admin");
putPage(CreateOrgPage.DEFAULT_PATH, new CreateOrgPage(), "Organisation Admin");
PrintWriter out = resp.getWriter();
HashMap<String, Object> map = new HashMap<String, Object>();
MyDetailsForm form = new MyDetailsForm(req, getUser(req));
- MyListingForm listingForm = new MyListingForm(req, getUser(req));
map.put("detailsForm", form);
- map.put("contactMeForm", listingForm);
if (LoginPage.getUser(req).getOrganisations().size() != 0) {
map.put("orgaForm", new MyOrganisationsForm(req));
}
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
- if (req.getParameter("processContact") != null) {
- Form.getForm(req, MyListingForm.class).submit(resp.getWriter(), req);
- } else if (req.getParameter("processDetails") != null) {
+ if (req.getParameter("processDetails") != null) {
Form.getForm(req, MyDetailsForm.class).submit(resp.getWriter(), req);
}
super.doPost(req, resp);
<?=$detailsForm?>
-<h2><?=_My Listing?></h2>
-<?=$contactMeForm?>
<? if($orgaForm) { ?>
<?=$orgaForm?>
<? } ?>
private static Template template;
static {
- template = new Template(MyListingForm.class.getResource("MyOrganisationsForm.templ"));
+ template = new Template(MyOrganisationsForm.class.getResource("MyOrganisationsForm.templ"));
}
@Override
-package org.cacert.gigi.pages.account;
+package org.cacert.gigi.pages.wot;
import java.io.PrintWriter;
import java.util.Map;
@Override
public boolean submit(PrintWriter out, HttpServletRequest req) {
if (req.getParameter("listme") != null && req.getParameter("contactinfo") != null) {
- target.setDirectoryListing( !req.getParameter("listme").equals("0"));
- target.setContactInformation(req.getParameter("contactinfo"));
+ boolean on = !req.getParameter("listme").equals("0");
+ target.setDirectoryListing(on);
+ if (on) {
+ target.setContactInformation(req.getParameter("contactinfo"));
+ } else {
+ target.setContactInformation("");
+ }
return true;
}
return false;
} else {
vars.put("selected", "");
vars.put("notSelected", "selected");
- vars.put("activeInfo", "");
+ vars.put("activeInfo", target.getContactInformation());
}
template.output(out, l, vars);
}
--- /dev/null
+package org.cacert.gigi.pages.wot;
+
+import java.io.IOException;
+import java.util.HashMap;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.cacert.gigi.dbObjects.User;
+import org.cacert.gigi.output.template.Form;
+import org.cacert.gigi.pages.Page;
+import org.cacert.gigi.util.AuthorizationContext;
+
+public class MyListingPage extends Page {
+
+ public static final String PATH = "/wot/listing";
+
+ public MyListingPage() {
+ super("My Listing");
+ }
+
+ @Override
+ public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
+ if (Form.getForm(req, MyListingForm.class).submit(resp.getWriter(), req)) {
+ resp.sendRedirect(PATH);
+ return;
+ }
+ super.doPost(req, resp);
+ }
+
+ @Override
+ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
+ new MyListingForm(req, getUser(req)).output(resp.getWriter(), getLanguage(req), new HashMap<String, Object>());
+ }
+
+ @Override
+ public boolean isPermitted(AuthorizationContext ac) {
+ return ac != null && ac.getTarget() instanceof User;
+ }
+
+}
+++ /dev/null
-package org.cacert.gigi.pages.account;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLConnection;
-
-import org.cacert.gigi.testUtils.ClientTest;
-import org.cacert.gigi.testUtils.IOUtils;
-import org.junit.Test;
-
-public class TestContactInformation extends ClientTest {
-
- @Test
- public void testDirectoryListingToggle() throws IOException {
- assertNull(executeBasicWebInteraction(cookie, MyDetails.PATH, "listme=1&contactinfo=&processContact", 1));
- URLConnection url = new URL("https://" + getServerName() + MyDetails.PATH).openConnection();
- url.setRequestProperty("Cookie", cookie);
- String res = IOUtils.readURL(url);
- res = res.split(java.util.regex.Pattern.quote("</table>"))[1];
- assertThat(res, containsString("value=\"1\" selected"));
- assertNull(executeBasicWebInteraction(cookie, MyDetails.PATH, "listme=0&contactinfo=&processContact", 1));
- url = new URL("https://" + getServerName() + MyDetails.PATH).openConnection();
- url.setRequestProperty("Cookie", cookie);
- res = IOUtils.readURL(url);
- res = res.split(java.util.regex.Pattern.quote("</table>"))[1];
- assertTrue(res.contains("value=\"0\" selected"));
- }
-
- @Test
- public void testContactinfoSet() throws IOException {
- String text = createUniqueName();
- assertNull(executeBasicWebInteraction(cookie, MyDetails.PATH, "listme=1&contactinfo=" + text + "&processContact", 1));
- URLConnection url = new URL("https://" + getServerName() + MyDetails.PATH).openConnection();
- url.setRequestProperty("Cookie", cookie);
- String res = IOUtils.readURL(url);
- res = res.split(java.util.regex.Pattern.quote("</table>"))[1];
- assertThat(res, containsString(text));
- }
-}
--- /dev/null
+package org.cacert.gigi.pages.wot;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+
+import org.cacert.gigi.GigiApiException;
+import org.cacert.gigi.testUtils.ClientTest;
+import org.cacert.gigi.testUtils.IOUtils;
+import org.junit.Test;
+
+public class TestListing extends ClientTest {
+
+ @Test
+ public void testListing() throws IOException, GigiApiException {
+ String c = IOUtils.readURL(get(MyListingPage.PATH));
+ // Default settings not listed, empty text
+ assertThat(c, not(containsString("value=\"1\" selected")));
+ assertThat(c, containsString("value=\"0\" selected"));
+ assertThat(c, containsString("></textarea>"));
+
+ assertEquals(302, post(MyListingPage.PATH, "listme=0&contactinfo=a").getResponseCode());
+ c = IOUtils.readURL(get(MyListingPage.PATH));
+ assertThat(c, not(containsString("value=\"1\" selected")));
+ assertThat(c, containsString("value=\"0\" selected"));
+ assertThat(c, containsString("></textarea>"));
+
+ assertEquals(302, post(MyListingPage.PATH, "listme=1&contactinfo=a").getResponseCode());
+ c = IOUtils.readURL(get(MyListingPage.PATH));
+ assertThat(c, containsString("value=\"1\" selected"));
+ assertThat(c, not(containsString("value=\"0\" selected")));
+ assertThat(c, containsString(">a</textarea>"));
+
+ assertEquals(302, post(MyListingPage.PATH, "listme=1&contactinfo=b").getResponseCode());
+ c = IOUtils.readURL(get(MyListingPage.PATH));
+ assertThat(c, containsString("value=\"1\" selected"));
+ assertThat(c, not(containsString("value=\"0\" selected")));
+ assertThat(c, containsString(">b</textarea>"));
+
+ assertEquals(302, post(MyListingPage.PATH, "listme=0&contactinfo=b").getResponseCode());
+ c = IOUtils.readURL(get(MyListingPage.PATH));
+ assertThat(c, containsString("value=\"0\" selected"));
+ assertThat(c, not(containsString("value=\"1\" selected")));
+ assertThat(c, containsString("></textarea>"));
+ }
+}
int id = rs.getInt(1);
File crt = KeyStorage.locateCrt(id);
worked = true;
+ System.out.println("Revoke faked: " + id);
revokeCompleted.setInt(1, id);
revokeCompleted.execute();
finishJob.setInt(1, rs.getInt(3));