upd: remove directory listing information
authorFelix Dörre <felix@dogcraft.de>
Thu, 14 Jul 2016 10:33:03 +0000 (12:33 +0200)
committerFelix Dörre <felix@dogcraft.de>
Fri, 15 Jul 2016 08:45:09 +0000 (10:45 +0200)
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

src/org/cacert/gigi/Gigi.java
src/org/cacert/gigi/database/DatabaseConnection.java
src/org/cacert/gigi/database/tableStructure.sql
src/org/cacert/gigi/database/upgrade/from_17.sql [new file with mode: 0644]
src/org/cacert/gigi/dbObjects/User.java
src/org/cacert/gigi/pages/wot/MyListingForm.java [deleted file]
src/org/cacert/gigi/pages/wot/MyListingForm.templ [deleted file]
src/org/cacert/gigi/pages/wot/MyListingPage.java [deleted file]
tests/org/cacert/gigi/pages/wot/TestListing.java [deleted file]

index cb8c389e2fae0a1b68bc640b5652e9528779aea9..37d0e62a0b6cdda673ecf668f9bf806d5353b115 100644 (file)
@@ -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");
index f2c5d5fa3c09719dd570fe25b868699d9fc521df..0be7becdf90093ee8dddfd0693a77256656a9377 100644 (file)
@@ -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;
 
index cc2aebd01f5f01f7fa5b09c24295b357f8af9003..0764954c06358c3ad45d662dc0233849967dbc33 100644 (file)
@@ -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 (file)
index 0000000..a3e852c
--- /dev/null
@@ -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";
index fe9ef7541d6f51fa616e84f7e1ee505bf695abc9..c0b0128bdd37e28040605d141a80dd3fcad24b49 100644 (file)
@@ -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 (file)
index 97218a5..0000000
+++ /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<String, Object> 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 (file)
index 49902af..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<table class="table">
-  <tr>
-    <th colspan="2"><?=_My Listing?></td>
-  </tr>
-  <tr>
-    <td><?=_Directory Listing?>:</td>
-    <td>
-       <select name="listme">
-               <option value="0" <?=$notSelected?>><?=_I don't want to be listed?></option>
-               <option value="1" <?=$selected?>><?=_I want to be listed?></option>
-       </select>
-    </td>
-  </tr>
-  <tr>
-    <td><?=_Contact information?>:</td>
-    <td><textarea class="form-control" name="contactinfo" cols="40" rows="5" wrap="virtual"><?=$activeInfo?></textarea></td>
-  </tr>
-  <tr>
-    <td colspan="2"><input type="submit" name="processContact" value="<?=_Update?>"></td>
-  </tr>
-</table>
\ 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 (file)
index 0b64b2e..0000000
+++ /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<String, Object>());
-    }
-
-    @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 (file)
index 2747c50..0000000
+++ /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("></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>"));
-    }
-}