Author: toad
Date: 2006-01-16 18:58:14 +0000 (Mon, 16 Jan 2006)
New Revision: 7867
Modified:
trunk/freenet/src/freenet/keys/ClientCHK.java
trunk/freenet/src/freenet/keys/FreenetURI.java
trunk/freenet/src/freenet/keys/InsertableClientSSK.java
trunk/freenet/src/freenet/node/TextModeClientInterface.java
trunk/freenet/src/freenet/node/Version.java
Log:
357: (mandatory)
Single slash migration.
Modified: trunk/freenet/src/freenet/keys/ClientCHK.java
===================================================================
--- trunk/freenet/src/freenet/keys/ClientCHK.java 2006-01-16 07:19:37 UTC
(rev 7866)
+++ trunk/freenet/src/freenet/keys/ClientCHK.java 2006-01-16 18:58:14 UTC
(rev 7867)
@@ -132,7 +132,7 @@
*/
public FreenetURI getURI() {
byte[] extra = getExtra();
- return new FreenetURI("CHK", "", routingKey, cryptoKey, extra);
+ return new FreenetURI("CHK", null, routingKey, cryptoKey, extra);
}
/**
Modified: trunk/freenet/src/freenet/keys/FreenetURI.java
===================================================================
--- trunk/freenet/src/freenet/keys/FreenetURI.java 2006-01-16 07:19:37 UTC
(rev 7866)
+++ trunk/freenet/src/freenet/keys/FreenetURI.java 2006-01-16 18:58:14 UTC
(rev 7867)
@@ -21,16 +21,19 @@
* FreenetURI handles parsing and creation of the Freenet URI format, defined
* as follows:
* <p>
- *
<code>freenet:[KeyType@]RoutingKey,CryptoKey[,n1=v1,n2=v2,...][/docname][//metastring]</code>
+ *
<code>freenet:[KeyType@]RoutingKey,CryptoKey[,n1=v1,n2=v2,...][/docname][/metastring]</code>
* </p>
* <p>
* where KeyType is the TLA of the key (currently SVK, SSK, KSK, or CHK). If
* omitted, KeyType defaults to KSK.
+ * BUT: CHKs don't support or require a docname.
+ * KSKs and SSKs do.
+ * Therefore CHKs go straight into metastrings.
* </p>
* <p>
* For KSKs, the string keyword (docname) takes the RoutingKey position and the
* remainder of the fields are inapplicable (except metastring). Examples:
- * <coe>freenet:KSK at foo//bar freenet:KSK at test.html
freenet:test.html</code>.
+ * <coe>freenet:KSK at foo/bar freenet:KSK at test.html
freenet:test.html</code>.
* </p>
* <p>
* RoutingKey is the modified Base64 encoded key value. CryptoKey is the
@@ -137,8 +140,7 @@
// decode keyType
int atchar = URI.indexOf('@');
if (atchar == -1) {
- keyType = "KSK";
- atchar = colon;
+ throw new MalformedURLException();
} else {
keyType = URI.substring(colon + 1,
atchar).toUpperCase().trim();
}
@@ -147,30 +149,26 @@
// decode metaString
int slash2;
Vector sv = new Vector();
- while ((slash2 = URI.lastIndexOf("//")) != -1) {
- String s = urlDecode(URI.substring(slash2 +
"//".length()));
+ while ((slash2 = URI.lastIndexOf("/")) != -1) {
+ String s = urlDecode(URI.substring(slash2 +
"/".length()));
if (s != null)
sv.addElement(urlDecode(s));
URI = URI.substring(0, slash2);
}
+ if(!"CHK".equals(keyType)) {
+ // docName not necessary, nor is it supported, for CHKs.
+
+ if(sv.isEmpty())
+ throw new MalformedURLException("No docname");
+ docName = (String) sv.remove(sv.size()-1);
+ }
+
if (!sv.isEmpty()) {
metaStr = new String[sv.size()];
for (int i = 0; i < metaStr.length; i++)
metaStr[i] = (String)
sv.elementAt(metaStr.length - 1 - i);
}
- // decode docName
- if ("KSK".equals(keyType)) {
- docName = urlDecode(URI);
- return;
- }
-
- int slash1 = URI.indexOf('/');
- if (slash1 != -1) {
- docName = urlDecode(URI.substring(slash1 + 1));
- URI = URI.substring(0, slash1);
- }
-
// URI now contains: routingKey[,cryptoKey][,metaInfo]
StringTokenizer st = new StringTokenizer(URI, ",");
try {
@@ -379,7 +377,7 @@
b.append(urlEncode(docName));
if (metaStr != null) {
for (int i = 0; i < metaStr.length; i++) {
- b.append("//").append(urlEncode(metaStr[i]));
+ b.append("/").append(urlEncode(metaStr[i]));
}
}
return b.toString();
Modified: trunk/freenet/src/freenet/keys/InsertableClientSSK.java
===================================================================
--- trunk/freenet/src/freenet/keys/InsertableClientSSK.java 2006-01-16
07:19:37 UTC (rev 7866)
+++ trunk/freenet/src/freenet/keys/InsertableClientSSK.java 2006-01-16
18:58:14 UTC (rev 7867)
@@ -37,6 +37,8 @@
return ClientKSK.create(uri);
if(!uri.getKeyType().equalsIgnoreCase("SSK"))
throw new MalformedURLException();
+ if(uri.getDocName() == null || uri.getDocName().length() == 0)
+ throw new MalformedURLException("SSK URIs must have a
document name (to avoid ambiguity)");
DSAGroup g = Global.DSAgroupBigA;
DSAPrivateKey privKey = new DSAPrivateKey(new
NativeBigInteger(1, uri.getKeyVal()));
DSAPublicKey pubKey = new DSAPublicKey(g, privKey);
Modified: trunk/freenet/src/freenet/node/TextModeClientInterface.java
===================================================================
--- trunk/freenet/src/freenet/node/TextModeClientInterface.java 2006-01-16
07:19:37 UTC (rev 7866)
+++ trunk/freenet/src/freenet/node/TextModeClientInterface.java 2006-01-16
18:58:14 UTC (rev 7867)
@@ -393,6 +393,11 @@
InsertableClientSSK key = InsertableClientSSK.createRandom(r);
System.out.println("Insert URI:
"+key.getInsertURI().toString(false));
System.out.println("Request URI:
"+key.getURI().toString(false));
+ FreenetURI insertURI =
key.getInsertURI().setDocName("testsite");
+ String fixedInsertURI = insertURI.toString(false);
+ System.out.println("Note that you MUST add a filename to the
end of the above URLs e.g.:\n"+fixedInsertURI);
+ System.out.println("Normally you will then do PUTSSKDIR:<insert
URI>#<directory to upload>, for
example:\nPUTSSKDIR:"+fixedInsertURI+"#directoryToUpload/");
+ System.out.println("This will then produce a manifest site
containing all the files, the default document can be accessed
at\n"+insertURI.addMetaStrings(new String[] { "" }).toString(false));
} else if(uline.startsWith("PUTSSK:")) {
String cmd = line.substring("PUTSSK:".length());
cmd = cmd.trim();
Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-01-16 07:19:37 UTC (rev
7866)
+++ trunk/freenet/src/freenet/node/Version.java 2006-01-16 18:58:14 UTC (rev
7867)
@@ -20,10 +20,10 @@
public static final String protocolVersion = "1.0";
/** The build number of the current revision */
- public static final int buildNumber = 356;
+ public static final int buildNumber = 357;
/** Oldest build of Fred we will talk to */
- public static final int lastGoodBuild = 356;
+ public static final int lastGoodBuild = 357;
/** The highest reported build of fred */
public static int highestSeenBuild = buildNumber;