Author: batosai
Date: 2008-08-04 21:11:14 +0000 (Mon, 04 Aug 2008)
New Revision: 21602

Modified:
   trunk/apps/WoT/src/plugins/WoT/WoTplugin.java
Log:
Added an identity creation form.

Modified: trunk/apps/WoT/src/plugins/WoT/WoTplugin.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/WoTplugin.java       2008-08-04 20:04:32 UTC 
(rev 21601)
+++ trunk/apps/WoT/src/plugins/WoT/WoTplugin.java       2008-08-04 21:11:14 UTC 
(rev 21602)
@@ -54,7 +54,6 @@

                pm.addNavigationLink(SELF_URI, "Home", "Home page", false, 
null);
                pm.addNavigationLink(SELF_URI + "/ownidentities", "Own 
Identities", "Manage your own identities", false, null);
-               pm.addNavigationLink(SELF_URI + "/test", "Test", "Testing 
page", false, null);
                pm.addNavigationLink("/plugins/", "Plugins page", "Back to 
Plugins page", false, null);

                client = pr.getHLSimpleClient();
@@ -74,6 +73,9 @@
                if(page.equals("/ownidentities")) {
                        return makeOwnIdentitiesPage();
                }
+               if(page.equals("/createIdentity")) {
+                       return makeCreateIdentityPage();
+               }
                else {
                        return makeHomePage();
                }
@@ -81,16 +83,7 @@

        @Override
        public String handleHTTPPost(HTTPRequest request) throws 
PluginHTTPException {
-               
-               String page = request.getPath().substring(SELF_URI.length());
-               if(page.equals("/createIdentity")) {
-                       FreenetURI[] keypair = client.generateKeyPair("WoT");
-                       FreenetURI insertURI = 
keypair[0].setKeyType("USK").setSuggestedEdition(0);
-                       FreenetURI requestURI = 
keypair[1].setKeyType("USK").setSuggestedEdition(0);
-                       
-                       return insertURI + "<br>" + requestURI;
-               }
-               else return makeHomePage();
+               return null;
        }

        @Override
@@ -138,11 +131,37 @@
                }
                else {
                        while(ownIdentities.hasNext()) {
-                               boxContent.addChild(new HTMLNode("p", 
ownIdentities.next().getRequestURI()));
+                               boxContent.addChild(new HTMLNode("p", 
ownIdentities.next().getRequestURI().toString()));
                        }
                }
+
+               boxContent.addChild(new HTMLNode("a", "href", SELF_URI + 
"/createIdentity", "Create a new Identity"));
+       
+               contentNode.addChild(box);
+               return pageNode.generate();
+       }
+       
+       private String makeCreateIdentityPage() {

+               HTMLNode pageNode = getPageNode();
+               HTMLNode contentNode = pm.getContentNode(pageNode);
+               HTMLNode box = pm.getInfobox("Identity creation");
+               HTMLNode boxContent = pm.getContentNode(box);
+               
+               FreenetURI[] keypair = client.generateKeyPair("WoT");
+               
                HTMLNode createForm = pr.addFormChild(boxContent, SELF_URI + 
"/createIdentity", "createForm");
+               createForm.addChild("#", "Request URI : ");
+               createForm.addChild("input", new String[] { "type", "name", 
"size", "value" }, new String[] { "text", "requestURI", "70", 
keypair[1].toString() });
+               createForm.addChild("br");
+               createForm.addChild("#", "Insert URI : ");
+               createForm.addChild("input", new String[] { "type", "name", 
"size", "value" }, new String[] { "text", "insertURI", "70", 
keypair[0].toString() });
+               createForm.addChild("br");
+               createForm.addChild("#", "Publish trust list ");
+               createForm.addChild("input", new String[] { "type", "name", 
"checked" }, new String[] { "checkbox", "publishTrustList", "true"});
+               createForm.addChild("br");
+               
+               
                createForm.addChild("input", new String[] { "type", "name", 
"value" }, new String[] { "submit", "create", "Create a new identity !" });

                contentNode.addChild(box);


Reply via email to