From: Felix Dörre Date: Thu, 14 Jul 2016 10:33:03 +0000 (+0200) Subject: upd: remove directory listing information X-Git-Url: https://code.wpia.club/?p=gigi.git;a=commitdiff_plain;h=4b9842acd7dd0e79de8fc3f88cb8241f9b2f134e upd: remove directory listing information that has to be managed on a different system, as the information is not required for deciding upon issuing certificates (and adding location data involves adding more external data sources). Change-Id: Ibc1d4876a18337152f901b4d65743a13406d383f --- diff --git a/src/org/cacert/gigi/Gigi.java b/src/org/cacert/gigi/Gigi.java index cb8c389e..37d0e62a 100644 --- a/src/org/cacert/gigi/Gigi.java +++ b/src/org/cacert/gigi/Gigi.java @@ -64,7 +64,6 @@ import org.cacert.gigi.pages.main.RegisterPage; 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; @@ -141,7 +140,6 @@ public final class Gigi extends HttpServlet { putPage(AssurePage.PATH + "/*", new AssurePage(), "Web of Trust"); putPage(MyPoints.PATH, new MyPoints(), "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"); diff --git a/src/org/cacert/gigi/database/DatabaseConnection.java b/src/org/cacert/gigi/database/DatabaseConnection.java index f2c5d5fa..0be7becd 100644 --- a/src/org/cacert/gigi/database/DatabaseConnection.java +++ b/src/org/cacert/gigi/database/DatabaseConnection.java @@ -122,7 +122,7 @@ public class DatabaseConnection { } - public static final int CURRENT_SCHEMA_VERSION = 17; + public static final int CURRENT_SCHEMA_VERSION = 18; public static final int CONNECTION_TIMEOUT = 24 * 60 * 60; diff --git a/src/org/cacert/gigi/database/tableStructure.sql b/src/org/cacert/gigi/database/tableStructure.sql index cc2aebd0..0764954c 100644 --- a/src/org/cacert/gigi/database/tableStructure.sql +++ b/src/org/cacert/gigi/database/tableStructure.sql @@ -18,17 +18,9 @@ CREATE TABLE "users" ( "suffix" varchar(50) NOT NULL DEFAULT '', "dob" date NOT NULL, "verified" boolean NOT NULL DEFAULT 'false', - "ccid" int NOT NULL DEFAULT '0', - "regid" int NOT NULL DEFAULT '0', - "locid" int NOT NULL DEFAULT '0', - "listme" boolean NOT NULL DEFAULT 'false', - "contactinfo" varchar(255) NOT NULL DEFAULT '', "language" varchar(5) NOT NULL DEFAULT '', PRIMARY KEY ("id") ); -CREATE INDEX ON "users" ("ccid"); -CREATE INDEX ON "users" ("regid"); -CREATE INDEX ON "users" ("locid"); CREATE INDEX ON "users" ("email"); CREATE INDEX ON "users" ("verified"); @@ -385,7 +377,7 @@ CREATE TABLE "schemeVersion" ( "version" smallint NOT NULL, PRIMARY KEY ("version") ); -INSERT INTO "schemeVersion" (version) VALUES(17); +INSERT INTO "schemeVersion" (version) VALUES(18); DROP TABLE IF EXISTS `passwordResetTickets`; CREATE TABLE `passwordResetTickets` ( diff --git a/src/org/cacert/gigi/database/upgrade/from_17.sql b/src/org/cacert/gigi/database/upgrade/from_17.sql new file mode 100644 index 00000000..a3e852c1 --- /dev/null +++ b/src/org/cacert/gigi/database/upgrade/from_17.sql @@ -0,0 +1,6 @@ +ALTER TABLE "users" DROP "listme"; +ALTER TABLE "users" DROP "contactinfo"; + +ALTER TABLE "users" DROP "ccid"; +ALTER TABLE "users" DROP "regid"; +ALTER TABLE "users" DROP "locid"; diff --git a/src/org/cacert/gigi/dbObjects/User.java b/src/org/cacert/gigi/dbObjects/User.java index fe9ef754..c0b0128b 100644 --- a/src/org/cacert/gigi/dbObjects/User.java +++ b/src/org/cacert/gigi/dbObjects/User.java @@ -362,40 +362,6 @@ public class User extends CertificateOwner { } - public boolean wantsDirectoryListing() { - try (GigiPreparedStatement get = new GigiPreparedStatement("SELECT listme FROM users WHERE id=?")) { - get.setInt(1, getId()); - GigiResultSet exec = get.executeQuery(); - return exec.next() && exec.getBoolean("listme"); - } - } - - public String getContactInformation() { - try (GigiPreparedStatement get = new GigiPreparedStatement("SELECT contactinfo FROM users WHERE id=?")) { - get.setInt(1, getId()); - - GigiResultSet exec = get.executeQuery(); - exec.next(); - return exec.getString("contactinfo"); - } - } - - public void setDirectoryListing(boolean on) { - try (GigiPreparedStatement update = new GigiPreparedStatement("UPDATE users SET listme = ? WHERE id = ?")) { - update.setBoolean(1, on); - update.setInt(2, getId()); - update.executeUpdate(); - } - } - - public void setContactInformation(String contactInfo) { - try (GigiPreparedStatement update = new GigiPreparedStatement("UPDATE users SET contactinfo = ? WHERE id = ?")) { - update.setString(1, contactInfo); - update.setInt(2, getId()); - update.executeUpdate(); - } - } - public boolean isInGroup(Group g) { return groups.contains(g); } diff --git a/src/org/cacert/gigi/pages/wot/MyListingForm.java b/src/org/cacert/gigi/pages/wot/MyListingForm.java deleted file mode 100644 index 97218a5c..00000000 --- a/src/org/cacert/gigi/pages/wot/MyListingForm.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.cacert.gigi.pages.wot; - -import java.io.PrintWriter; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import org.cacert.gigi.dbObjects.User; -import org.cacert.gigi.localisation.Language; -import org.cacert.gigi.output.template.Form; -import org.cacert.gigi.output.template.Template; - -public class MyListingForm extends Form { - - private static Template template; - - static { - template = new Template(MyListingForm.class.getResource("MyListingForm.templ")); - } - - private User target; - - public MyListingForm(HttpServletRequest hsr, User target) { - super(hsr); - this.target = target; - } - - @Override - public boolean submit(PrintWriter out, HttpServletRequest req) { - if (req.getParameter("listme") != null && req.getParameter("contactinfo") != null) { - boolean on = !req.getParameter("listme").equals("0"); - target.setDirectoryListing(on); - if (on) { - target.setContactInformation(req.getParameter("contactinfo")); - } else { - target.setContactInformation(""); - } - return true; - } - return false; - } - - @Override - protected void outputContent(PrintWriter out, Language l, Map vars) { - if (target.wantsDirectoryListing()) { - vars.put("selected", "selected"); - vars.put("notSelected", ""); - vars.put("activeInfo", target.getContactInformation()); - } else { - vars.put("selected", ""); - vars.put("notSelected", "selected"); - vars.put("activeInfo", target.getContactInformation()); - } - template.output(out, l, vars); - } - -} diff --git a/src/org/cacert/gigi/pages/wot/MyListingForm.templ b/src/org/cacert/gigi/pages/wot/MyListingForm.templ deleted file mode 100644 index 49902afe..00000000 --- a/src/org/cacert/gigi/pages/wot/MyListingForm.templ +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - -
-
: - -
:
\ No newline at end of file diff --git a/src/org/cacert/gigi/pages/wot/MyListingPage.java b/src/org/cacert/gigi/pages/wot/MyListingPage.java deleted file mode 100644 index 0b64b2e4..00000000 --- a/src/org/cacert/gigi/pages/wot/MyListingPage.java +++ /dev/null @@ -1,41 +0,0 @@ -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()); - } - - @Override - public boolean isPermitted(AuthorizationContext ac) { - return ac != null && ac.getTarget() instanceof User; - } - -} diff --git a/tests/org/cacert/gigi/pages/wot/TestListing.java b/tests/org/cacert/gigi/pages/wot/TestListing.java deleted file mode 100644 index 2747c50b..00000000 --- a/tests/org/cacert/gigi/pages/wot/TestListing.java +++ /dev/null @@ -1,47 +0,0 @@ -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(">")); - - 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(">")); - - 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")); - - 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")); - - 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(">")); - } -}