Author: batosai
Date: 2008-08-24 10:44:25 +0000 (Sun, 24 Aug 2008)
New Revision: 22125
Modified:
trunk/apps/WoT/src/plugins/WoT/WebInterface.java
trunk/apps/WoT/src/plugins/WoT/WoTplugin.java
Log:
Added the ability to restore an identity from Freenet (bug #2528). The user
just needs his keypair.
Modified: trunk/apps/WoT/src/plugins/WoT/WebInterface.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/WebInterface.java 2008-08-24 10:35:58 UTC
(rev 22124)
+++ trunk/apps/WoT/src/plugins/WoT/WebInterface.java 2008-08-24 10:44:25 UTC
(rev 22125)
@@ -116,8 +116,27 @@
createForm.addChild("span", new String[] {"title", "style"},
new String[] { "No spaces or special characters.", "border-bottom: 1px dotted;
cursor: help;"} , "NickName : ");
createForm.addChild("input", new String[] {"type", "name",
"size"}, new String[] {"text", "nickName", "30"});
createForm.addChild("input", new String[] { "type", "name",
"value" }, new String[] { "submit", "create", "Create a new identity !" });
-
+
contentNode.addChild(box);
+
+
+ // Form to restore an existing OwnIdentity from Freenet
+ HTMLNode restoreBox = pm.getInfobox("Restore an identity from
Freenet");
+ HTMLNode restoreBoxContent = pm.getContentNode(restoreBox);
+
+ restoreBoxContent.addChild("p", "Use this if you lost your
database for some reason (crash, reinstall...) but still have your identity's
keys :");
+
+ HTMLNode restoreForm = pr.addFormChild(restoreBoxContent,
SELF_URI + "/restoreIdentity", "restoreForm");
+ restoreForm.addChild("input", new String[] { "type", "name",
"size", "value" }, new String[] { "text", "requestURI", "70", "Request URI" });
+ restoreForm.addChild("br");
+ restoreForm.addChild("input", new String[] { "type", "name",
"size", "value" }, new String[] { "text", "insertURI", "70", "InsertURI" });
+ restoreForm.addChild("br");
+ restoreForm.addChild("input", new String[] { "type", "name",
"value" }, new String[] { "submit", "restore", "Restore this identity !" });
+
+ restoreBoxContent.addChild("p", "Please don't use that identity
(set trust, edit parameters...) until it has been restored from Freenet, or you
might loose all its content.");
+
+ contentNode.addChild(restoreBox);
+
return pageNode.generate();
}
Modified: trunk/apps/WoT/src/plugins/WoT/WoTplugin.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/WoTplugin.java 2008-08-24 10:35:58 UTC
(rev 22124)
+++ trunk/apps/WoT/src/plugins/WoT/WoTplugin.java 2008-08-24 10:44:25 UTC
(rev 22125)
@@ -145,7 +145,10 @@
else if(page.equals("/editIdentity")) {
return
web.makeEditIdentityPage(request.getPartAsString("id", 1024));
}
-
+ else if(page.equals("/restoreIdentity")) {
+
restoreIdentity(request.getPartAsString("requestURI", 1024),
request.getPartAsString("insertURI", 1024));
+ return web.makeOwnIdentitiesPage();
+ }
else {
return web.makeHomePage();
}
@@ -155,6 +158,15 @@
}
}
+ private void restoreIdentity(String requestURI, String insertURI)
throws InvalidParameterException {
+
+ OwnIdentity id = new OwnIdentity(insertURI, requestURI, new
Date(), new Date(0), "Restore in prgress...", "false");
+ db.store(id);
+ db.commit();
+
+ fetcher.fetch(id);
+ }
+
private void setTrust(HTTPRequest request) throws
NumberFormatException, TransformerConfigurationException,
FileNotFoundException, InvalidParameterException, UnknownIdentityException,
ParserConfigurationException, TransformerException, IOException,
InsertException {
setTrust( request.getPartAsString("truster", 1024),