Renamed lwNDN to NDN. Make test-get.html use NDN. Added test-put.html. Moved image-loader.html and image-sender.html to testing directory.
diff --git a/js/lwNDN.js b/js/NDN.js
similarity index 90%
rename from js/lwNDN.js
rename to js/NDN.js
index 25615fb..2acb031 100644
--- a/js/lwNDN.js
+++ b/js/NDN.js
@@ -1,16 +1,20 @@
-var lwNDN = function lwNDN(host,port){
- this.host = host;
- this.port = port;
+/**
+ * host is default '127.0.0.1'.
+ * port is default 9695.
+ */
+var NDN = function NDN(host, port){
+ this.host = (host || '127.0.0.1');
+ this.port = (port || 9695);
};
-lwNDN.prototype.createRoute = function(host,port){
+NDN.prototype.createRoute = function(host,port){
this.host=host;
this.port=port;
}
-lwNDN.prototype.get = function(message){
+NDN.prototype.get = function(message){
if(this.host!=null && this.port!=null){
var output ='';
message = message.trim();
@@ -65,7 +69,7 @@
}
-lwNDN.prototype.put = function(name,content){
+NDN.prototype.put = function(name,content){
if(this.host!=null && this.port!=null){
var co = this.get("/%C1.M.S.localhost/%C1.M.SRV/ccnd");
@@ -135,7 +139,6 @@
//return get_java_socket_bridge().putAnswer(outputHex,name);
-
var result = put(this.host,this.port, hex,name,outputHex);
diff --git a/js/image-loader.html b/js/image-loader.html
deleted file mode 100644
index 3fe6442..0000000
--- a/js/image-loader.html
+++ /dev/null
@@ -1,123 +0,0 @@
-<?xml version = "1.0" encoding="utf-8" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-"DTD/xhtml1-strict.dtd">
-<html xmlns = "http://www.w3.org/1999/xhtml">
-
-<head>
- <title>NDN Request </title>
- <script type="text/javascript" src="java_socket_bridge.js"></script>
-
- <script type="text/javascript" src="CCNProtocolDTags.js"></script>
-
- <script type="text/javascript" src="CCNTime.js"></script>
-
- <script type="text/javascript" src="Name.js"></script>
-
- <script type="text/javascript" src="ContentObject.js"></script>
-
- <script type="text/javascript" src="DateFormat.js"></script>
-
- <script type="text/javascript" src="Exclude.js"></script>
-
- <script type="text/javascript" src="ExcludeAny.js"></script>
-
- <script type="text/javascript" src="ExcludeComponent.js"></script>
-
- <script type="text/javascript" src="Interest.js"></script>
-
- <script type="text/javascript" src="KeyLocator.js"></script>
-
- <script type="text/javascript" src="PublisherID.js"></script>
-
- <script type="text/javascript" src="Signature.js"></script>
-
- <script type="text/javascript" src="SignedInfo.js"></script>
-
- <script type="text/javascript" src="PublisherPublicKeyDigest.js"></script>
-
- <script type="text/javascript" src="FaceInstance.js"></script>
-
- <script type="text/javascript" src="ForwardingEntry.js"></script>
-
-
- <script type="text/javascript" src="encoding/BinaryXMLEncoder.js"></script>
-
- <script type="text/javascript" src="encoding/BinaryXMLCodec.js"></script>
-
- <script type="text/javascript" src="encoding/BinaryXMLDecoder.js"></script>
-
- <script type="text/javascript" src="encoding/DataUtils.js"></script>
-
- <script type="text/javascript" src="encoding/EncodingUtils.js"></script>
-
- <script type="text/javascript" src="lwNDN.js"></script>
-
- <script language="JavaScript" type="text/javascript" src="security/KeyManager.js"></script>
-
- <script language="JavaScript" type="text/javascript" src="securityLib/jsbn.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/jsbn2.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/rsa.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/rsa2.js"></script>
-
- <script language="JavaScript" type="text/javascript" src="securityLib/sha1.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/sha256.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/sha512.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/md5.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/ripemd160.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/base64.js"></script>
-
- <script language="JavaScript" type="text/javascript" src="securityLib/rsapem-1.1.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/rsasign-1.2.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/asn1hex-1.1.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/x509-1.1.js"></script>
-
- <script type="text/javascript">
- var loadedImageString = "";
- var connector = new lwNDN('127.0.0.1', 9695);
- var pieceNumber = 0;
- var count = 0;
- var end = false;
- var LOG = 0;
- var pieceSize = 1000;
-
-
- function getPiece(){
- if(!pieceNumber) pieceNumber = 0;
- var contentName = "/image/piece" + pieceNumber;
-// var connector = new lwNDN('127.0.0.1', 9695);
- var co = connector.get( contentName );
-
- if(co){
- loadedImageString += DataUtils.toString(co.content);
- console.log("Received length: " + co.content.length);
- if(co.content.length == pieceSize){
- pieceNumber += co.content.length;
- getPiece();
- }
- else document.getElementById('image').src += loadedImageString;
- }
- }
-
-
-
-
-
- </script>
-
-</head>
-<body >
- <div>
- <button onclick="getPiece()">Get image</button>
- </div>
- <div >
- <applet id="JavaSocketBridge" archive="JavaSocketBridge.jar" code="JavaSocketBridge.class" width="0" height="0">
- </applet>
- </div>
-
- <p id="result"></p>
- <div>
- <img id="image" src="data:image/png;base64," alt="Image placeholder" />
- </div>
-
-</body>
-</html>
\ No newline at end of file
diff --git a/js/publish-data.html b/js/publish-data.html
deleted file mode 100644
index d396452..0000000
--- a/js/publish-data.html
+++ /dev/null
@@ -1,183 +0,0 @@
-<?xml version = "1.0" encoding="utf-8" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-"DTD/xhtml1-strict.dtd">
-<html xmlns = "http://www.w3.org/1999/xhtml">
-
-<head>
- <title>NDN Publish</title>
- <script type="text/javascript" src="java_socket_bridge.js"></script>
-
- <script type="text/javascript" src="CCNProtocolDTags.js"></script>
-
- <script type="text/javascript" src="CCNTime.js"></script>
-
- <script type="text/javascript" src="Name.js"></script>
-
- <script type="text/javascript" src="ContentObject.js"></script>
-
- <script type="text/javascript" src="DateFormat.js"></script>
-
- <script type="text/javascript" src="Exclude.js"></script>
-
- <script type="text/javascript" src="ExcludeAny.js"></script>
-
- <script type="text/javascript" src="ExcludeComponent.js"></script>
-
- <script type="text/javascript" src="Interest.js"></script>
-
- <script type="text/javascript" src="KeyLocator.js"></script>
-
- <script type="text/javascript" src="PublisherID.js"></script>
-
- <script type="text/javascript" src="Signature.js"></script>
-
- <script type="text/javascript" src="SignedInfo.js"></script>
-
- <script type="text/javascript" src="PublisherPublicKeyDigest.js"></script>
-
- <script type="text/javascript" src="FaceInstance.js"></script>
-
- <script type="text/javascript" src="ForwardingEntry.js"></script>
-
- <script type="text/javascript" src="encoding/BinaryXMLEncoder.js"></script>
-
- <script type="text/javascript" src="encoding/BinaryXMLCodec.js"></script>
-
- <script type="text/javascript" src="encoding/BinaryXMLDecoder.js"></script>
-
- <script type="text/javascript" src="encoding/DataUtils.js"></script>
-
- <script type="text/javascript" src="encoding/EncodingUtils.js"></script>
-
- <script type="text/javascript" src="lwNDN.js"></script>
-
-
- <script language="JavaScript" type="text/javascript" src="security/KeyManager.js"></script>
-
- <script language="JavaScript" type="text/javascript" src="securityLib/jsbn.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/jsbn2.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/rsa.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/rsa2.js"></script>
-
- <script language="JavaScript" type="text/javascript" src="securityLib/sha1.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/sha256.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/sha512.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/md5.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/ripemd160.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/base64.js"></script>
-
- <script language="JavaScript" type="text/javascript" src="securityLib/rsapem-1.1.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/rsasign-1.2.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/asn1hex-1.1.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/x509-1.1.js"></script>
-
-
- <script type="text/javascript">
- function run(){
-
- var ContentName = document.getElementById('contentname').value;
-
- var Content = document.getElementById('content').value;
-
- //createRoute('borges.metwi.ucla.edu', 9695);
-
-
-
-
- ///////////////////////////////////////
- //createRoute('localhost', 9695);
-
- //createRoute('131.179.141.15', 9695);
- //createRoute('borges.metwi.ucla.edu', 9695);
-
- //content object
- //var co = queryPrefix( Name );
-
- var connector = new lwNDN('127.0.0.1', 9695);
- //var connector = new lwNDN('131.179.141.15', 9695);
-
-
- var co = connector.put( ContentName, Content );
-
- ///////////////////////////////////////
-
- /*var output ="";
-
- if(co==-1)
- output+= "NO CONTENT FOUND"
- else if (co==-2)
- output+= "CONTENT NAME IS EMPTY"
- else{
- if(co.name!=null && co.Name.components!=null){
- output+= "NAME: ";
-
- for(var i=0;i<co.Name.Components.length;i++){
- output+= "/"+ toString(co.Name.Components[i]);
- }
- output+= "<br />";
- output+= "<br />";
- }
-
- if(co.content !=null){
- output += "CONTENT(ASCII): "+ toString(co.Content);
-
- output+= "<br />";
- output+= "<br />";
- }
- if(co.Content !=null){
- output += "CONTENT(hex): "+ toHex(co.Content);
-
- output+= "<br />";
- output+= "<br />";
- }
- if(co.signature !=null && co.signature.signature!=null){
-
- output += "SIGNATURE(hex): "+ toHex(co.signature.signature);
-
- output+= "<br />";
- output+= "<br />";
- }
- if(co.signedInfo!=null && co.SignedInfo.locator!=null && co.SignedInfo.Locator.Key!=null){
-
- output += "PUBLISHER KEY: "+ toHex(co.SignedInfo.Locator.Key);
-
- output+= "<br />";
- output+= "<br />";
-
- }
- }*/
-
- //document.getElementById('result').innerHTML = output;
- document.getElementById('result').innerHTML = 'Content \'' + Content + '\' was published with content name \'' + ContentName +'\'';
-
- }
-
- </script>
-
-</head>
-<body >
- <form>
- <div>
- <p>Please Enter a Content Name:</p>
-
- <input id="contentname" type="text" name="CONTENTNAME" value="/demo/message" />
-
- Please Enter the Content:<br />
-
- <textarea id="content" cols="40" rows="5" name="CONTENT" >This works!</textarea>
-
- <br />
- </div>
- </form>
- <div>
- <button onclick="run()">Publish</button>
- </div>
- <div >
- <applet id="JavaSocketBridge" archive="JavaSocketBridge.jar" code="JavaSocketBridge.class" width="0" height="0">
- </applet>
- </div>
-
- <p id="result"></p>
-
-</body>
-</html>
\ No newline at end of file
diff --git a/js/request-data.html b/js/request-data.html
deleted file mode 100644
index 9fb6a4f..0000000
--- a/js/request-data.html
+++ /dev/null
@@ -1,275 +0,0 @@
-<?xml version = "1.0" encoding="utf-8" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-"DTD/xhtml1-strict.dtd">
-<html xmlns = "http://www.w3.org/1999/xhtml">
-
-<head>
- <title>NDN Request </title>
- <script type="text/javascript" src="java_socket_bridge.js"></script>
-
- <script type="text/javascript" src="CCNProtocolDTags.js"></script>
-
- <script type="text/javascript" src="CCNTime.js"></script>
-
- <script type="text/javascript" src="Name.js"></script>
-
- <script type="text/javascript" src="ContentObject.js"></script>
-
- <script type="text/javascript" src="DateFormat.js"></script>
-
- <script type="text/javascript" src="Exclude.js"></script>
-
- <script type="text/javascript" src="ExcludeAny.js"></script>
-
- <script type="text/javascript" src="ExcludeComponent.js"></script>
-
- <script type="text/javascript" src="Interest.js"></script>
-
- <script type="text/javascript" src="KeyLocator.js"></script>
-
- <script type="text/javascript" src="PublisherID.js"></script>
-
- <script type="text/javascript" src="Signature.js"></script>
-
- <script type="text/javascript" src="SignedInfo.js"></script>
-
- <script type="text/javascript" src="PublisherPublicKeyDigest.js"></script>
-
- <script type="text/javascript" src="FaceInstance.js"></script>
-
- <script type="text/javascript" src="ForwardingEntry.js"></script>
-
-
- <script type="text/javascript" src="encoding/BinaryXMLEncoder.js"></script>
-
- <script type="text/javascript" src="encoding/BinaryXMLCodec.js"></script>
-
- <script type="text/javascript" src="encoding/BinaryXMLDecoder.js"></script>
-
- <script type="text/javascript" src="encoding/DataUtils.js"></script>
-
- <script type="text/javascript" src="encoding/EncodingUtils.js"></script>
-
- <script type="text/javascript" src="lwNDN.js"></script>
-
- <script language="JavaScript" type="text/javascript" src="security/KeyManager.js"></script>
-
- <script language="JavaScript" type="text/javascript" src="securityLib/jsbn.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/jsbn2.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/rsa.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/rsa2.js"></script>
-
- <script language="JavaScript" type="text/javascript" src="securityLib/sha1.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/sha256.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/sha512.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/md5.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/ripemd160.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/base64.js"></script>
-
- <script language="JavaScript" type="text/javascript" src="securityLib/rsapem-1.1.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/rsasign-1.2.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/asn1hex-1.1.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/x509-1.1.js"></script>
-
- <script type="text/javascript">
- function run(){
-
-
- var contentName = document.getElementById('contentname').value;
-
- ///////////////////////////////////////
- //createRoute('131.179.141.15', 9695);
- //createRoute('borges.metwi.ucla.edu', 9695);
- /// /ndn/ucla.edu/apps/hydra/mainvideo
- ///////////////////////////////////////
-
- var connector = new lwNDN('127.0.0.1', 9695);
-
- var co = connector.get( contentName );
-
- ///////////////////////////////////////
- //PRINT OUTPUT
- ///////////////////////////////////////
-
- var output ="";
-
- if(co==null)
- output+= "NO CONTENT FOUND"
- else{
- if(co.name!=null && co.name.components!=null){
- output+= "NAME: ";
-
- for(var i=0;i<co.name.components.length;i++){
- output+= "/"+ DataUtils.toString(co.name.components[i]);
- }
- output+= "<br />";
- output+= "<br />";
- }
-
- if(co.content !=null){
- output += "CONTENT(ASCII): "+ DataUtils.toString(co.content);
-
- output+= "<br />";
- output+= "<br />";
- }
- if(co.content !=null){
- output += "CONTENT(hex): "+ DataUtils.toHex(co.content);
-
- output+= "<br />";
- output+= "<br />";
- }
-
- if(co.signature !=null && co.signature.signature!=null){
-
- output += "SIGNATURE(hex): "+ DataUtils.toHex(co.signature.signature);
-
- output+= "<br />";
- output+= "<br />";
- }
- if(co.signedInfo !=null && co.signedInfo.publisher!=null && co.signedInfo.publisher.publisherPublicKeyDigest!=null){
-
- output += "Publisher Public Key Digest(hex): "+ DataUtils.toHex(co.signedInfo.publisher.publisherPublicKeyDigest);
-
- output+= "<br />";
- output+= "<br />";
- }
- if(co.signedInfo !=null && co.signedInfo.timestamp!=null){
-
- output += "TimeStamp: "+ co.signedInfo.timestamp.getJavascriptDate();
-
- output+= "<br />";
- output+= "<br />";
-
- output += "TimeStamp (MILLISECONDS): "+ co.signedInfo.timestamp.msec;
-
- output+= "<br />";
- output+= "<br />";
- }
- if(co.signedInfo!=null && co.signedInfo.locator!=null && co.signedInfo.locator.publicKey!=null){
-
- var publickey = rstr2b64(DataUtils.toString(co.signedInfo.locator.publicKey));
- var publickeyHex = DataUtils.toHex(co.signedInfo.locator.publicKey).toLowerCase();
- var publickeyString = DataUtils.toString(co.signedInfo.locator.publicKey);
-
- var signature = DataUtils.toHex(co.signature.signature).toLowerCase();
-
-
- var input = DataUtils.toString(co.rawSignatureData);
-
-
- output += "DER Certificate: "+publickey ;
-
- output+= "<br />";
- output+= "<br />";
-
- if(LOG>2) console.log(" ContentName + SignedInfo + Content = "+input);
- if(LOG>2) console.log(" PublicKey = "+publickey );
- if(LOG>2) console.log(" PublicKeyHex = "+publickeyHex );
- if(LOG>2) console.log(" PublicKeyString = "+publickeyString );
-
- if(LOG>2) console.log(" Signature "+signature );
-
- if(LOG>2) console.log(" Signature NOW IS" );
-
- if(LOG>2) console.log(co.signature.signature);
-
-
- /*var x509 = new X509();
-
- x509.readCertPEM(publickey);
-
-
- //x509.readCertPEMWithoutRSAInit(publickey);
-
- var result = x509.subjectPublicKeyRSA.verifyString(input, signature);*/
- //console.log('result is '+result);
-
-
- var kp = publickeyHex.slice(56,314);
-
- output += "PUBLISHER KEY(hex): "+kp ;
-
- output+= "<br />";
- output+= "<br />";
-
- console.log('PUBLIC KEY IN HEX is ');
- console.log(kp);
-
- var exp = publickeyHex.slice(318,324);
-
- console.log('kp size is '+kp.length );
- output += "exponent: "+exp ;
-
- output+= "<br />";
- output+= "<br />";
-
- console.log('EXPONENT is ');
- console.log(exp);
-
-
-
- /*var c1 = hex_sha256(input);
- var c2 = signature;
-
- if(LOG>4)console.log('input is ');
- if(LOG>4)console.log(input);
- if(LOG>4)console.log('C1 is ');
- if(LOG>4)console.log(c1);
- if(LOG>4)console.log('C2 is ');
- if(LOG>4)console.log(c2);
- var result = c1 == c2;*/
-
- var rsakey = new RSAKey();
-
- rsakey.setPublic(kp,exp);
-
- var result = rsakey.verifyByteArray(co.rawSignatureData,signature);
- // var result = rsakey.verifyString(input, signature);
-
-
-
- console.log('PUBLIC KEY n after is ');
- console.log(rsakey.n);
-
- console.log('EXPONENT e after is ');
- console.log(rsakey.e);
-
-
- if(result)
- output += 'SIGNATURE VALID';
- else
- output += 'SIGNATURE INVALID';
-
-
-
-
- //output += "VALID: "+ toHex(co.signedInfo.locator.publicKey);
-
- output+= "<br />";
- output+= "<br />";
-
-
- //if(LOG>4) console.log('str'[1]);
- }
- }
-
- document.getElementById('result').innerHTML = output;
- }
-
- </script>
-
-</head>
-<body >
- <form>
- Please Enter a Content Name:<br /><input id="contentname" type="text" name="CONTENTNAME" value="/PARC/abc" /> <br />
- </form>
- <button onclick="run()">Request Data!</button>
- <div >
- <applet id="JavaSocketBridge" archive="JavaSocketBridge.jar" code="JavaSocketBridge.class" width="0" height="0">
- </applet>
- </div>
-
- <p id="result"></p>
-
-</body>
-</html>
\ No newline at end of file
diff --git a/js/testing/image-loader.html b/js/testing/image-loader.html
new file mode 100644
index 0000000..a1eb6e1
--- /dev/null
+++ b/js/testing/image-loader.html
@@ -0,0 +1,122 @@
+<?xml version = "1.0" encoding="utf-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+"DTD/xhtml1-strict.dtd">
+<html xmlns = "http://www.w3.org/1999/xhtml">
+
+<head>
+ <title>NDN Image Loader</title>
+ <script type="text/javascript" src="../java_socket_bridge.js"></script>
+
+ <script type="text/javascript" src="../CCNProtocolDTags.js"></script>
+
+ <script type="text/javascript" src="../CCNTime.js"></script>
+
+ <script type="text/javascript" src="../Name.js"></script>
+
+ <script type="text/javascript" src="../ContentObject.js"></script>
+
+ <script type="text/javascript" src="../DateFormat.js"></script>
+
+ <script type="text/javascript" src="../Exclude.js"></script>
+
+ <script type="text/javascript" src="../ExcludeAny.js"></script>
+
+ <script type="text/javascript" src="../ExcludeComponent.js"></script>
+
+ <script type="text/javascript" src="../Interest.js"></script>
+
+ <script type="text/javascript" src="../KeyLocator.js"></script>
+
+ <script type="text/javascript" src="../PublisherID.js"></script>
+
+ <script type="text/javascript" src="../Signature.js"></script>
+
+ <script type="text/javascript" src="../SignedInfo.js"></script>
+
+ <script type="text/javascript" src="../PublisherPublicKeyDigest.js"></script>
+
+ <script type="text/javascript" src="../FaceInstance.js"></script>
+
+ <script type="text/javascript" src="../ForwardingEntry.js"></script>
+
+
+ <script type="text/javascript" src="../encoding/BinaryXMLEncoder.js"></script>
+
+ <script type="text/javascript" src="../encoding/BinaryXMLCodec.js"></script>
+
+ <script type="text/javascript" src="../encoding/BinaryXMLDecoder.js"></script>
+
+ <script type="text/javascript" src="../encoding/DataUtils.js"></script>
+
+ <script type="text/javascript" src="../encoding/EncodingUtils.js"></script>
+
+ <script type="text/javascript" src="../NDN.js"></script>
+
+ <script language="JavaScript" type="text/javascript" src="../security/KeyManager.js"></script>
+
+ <script language="JavaScript" type="text/javascript" src="../securityLib/jsbn.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/jsbn2.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/rsa.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/rsa2.js"></script>
+
+ <script language="JavaScript" type="text/javascript" src="../securityLib/sha1.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/sha256.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/sha512.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/md5.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/ripemd160.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/base64.js"></script>
+
+ <script language="JavaScript" type="text/javascript" src="../securityLib/rsapem-1.1.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/rsasign-1.2.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/asn1hex-1.1.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/x509-1.1.js"></script>
+
+ <script type="text/javascript">
+ var loadedImageString = "";
+ var connector = new NDN();
+ var pieceNumber = 0;
+ var count = 0;
+ var end = false;
+ var LOG = 0;
+ var pieceSize = 1000;
+
+
+ function getPiece(){
+ if(!pieceNumber) pieceNumber = 0;
+ var contentName = "/image/piece" + pieceNumber;
+ var co = connector.get( contentName );
+
+ if(co){
+ loadedImageString += DataUtils.toString(co.content);
+ console.log("Received length: " + co.content.length);
+ if(co.content.length == pieceSize){
+ pieceNumber += co.content.length;
+ getPiece();
+ }
+ else document.getElementById('image').src += loadedImageString;
+ }
+ }
+
+
+
+
+
+ </script>
+
+</head>
+<body >
+ <div>
+ <button onclick="getPiece()">Get image</button>
+ </div>
+ <div >
+ <applet id="JavaSocketBridge" archive="../JavaSocketBridge.jar" code="JavaSocketBridge.class" width="0" height="0">
+ </applet>
+ </div>
+
+ <p id="result"></p>
+ <div>
+ <img id="image" src="data:image/png;base64," alt="Image placeholder" />
+ </div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/js/image-sender.html b/js/testing/image-sender.html
similarity index 95%
rename from js/image-sender.html
rename to js/testing/image-sender.html
index 14fc8fb..4dca38a 100644
--- a/js/image-sender.html
+++ b/js/testing/image-sender.html
@@ -4,72 +4,72 @@
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
- <title>NDN Publish</title>
- <script type="text/javascript" src="java_socket_bridge.js"></script>
+ <title>NDN Image Sender</title>
+ <script type="text/javascript" src="../java_socket_bridge.js"></script>
- <script type="text/javascript" src="CCNProtocolDTags.js"></script>
+ <script type="text/javascript" src="../CCNProtocolDTags.js"></script>
- <script type="text/javascript" src="CCNTime.js"></script>
+ <script type="text/javascript" src="../CCNTime.js"></script>
- <script type="text/javascript" src="Name.js"></script>
+ <script type="text/javascript" src="../Name.js"></script>
- <script type="text/javascript" src="ContentObject.js"></script>
+ <script type="text/javascript" src="../ContentObject.js"></script>
- <script type="text/javascript" src="DateFormat.js"></script>
+ <script type="text/javascript" src="../DateFormat.js"></script>
- <script type="text/javascript" src="Exclude.js"></script>
+ <script type="text/javascript" src="../Exclude.js"></script>
- <script type="text/javascript" src="ExcludeAny.js"></script>
+ <script type="text/javascript" src="../ExcludeAny.js"></script>
- <script type="text/javascript" src="ExcludeComponent.js"></script>
+ <script type="text/javascript" src="../ExcludeComponent.js"></script>
- <script type="text/javascript" src="Interest.js"></script>
+ <script type="text/javascript" src="../Interest.js"></script>
- <script type="text/javascript" src="KeyLocator.js"></script>
+ <script type="text/javascript" src="../KeyLocator.js"></script>
- <script type="text/javascript" src="PublisherID.js"></script>
+ <script type="text/javascript" src="../PublisherID.js"></script>
- <script type="text/javascript" src="Signature.js"></script>
+ <script type="text/javascript" src="../Signature.js"></script>
- <script type="text/javascript" src="SignedInfo.js"></script>
+ <script type="text/javascript" src="../SignedInfo.js"></script>
- <script type="text/javascript" src="PublisherPublicKeyDigest.js"></script>
+ <script type="text/javascript" src="../PublisherPublicKeyDigest.js"></script>
- <script type="text/javascript" src="FaceInstance.js"></script>
+ <script type="text/javascript" src="../FaceInstance.js"></script>
- <script type="text/javascript" src="ForwardingEntry.js"></script>
+ <script type="text/javascript" src="../ForwardingEntry.js"></script>
- <script type="text/javascript" src="encoding/BinaryXMLEncoder.js"></script>
+ <script type="text/javascript" src="../encoding/BinaryXMLEncoder.js"></script>
- <script type="text/javascript" src="encoding/BinaryXMLCodec.js"></script>
+ <script type="text/javascript" src="../encoding/BinaryXMLCodec.js"></script>
- <script type="text/javascript" src="encoding/BinaryXMLDecoder.js"></script>
+ <script type="text/javascript" src="../encoding/BinaryXMLDecoder.js"></script>
- <script type="text/javascript" src="encoding/DataUtils.js"></script>
+ <script type="text/javascript" src="../encoding/DataUtils.js"></script>
- <script type="text/javascript" src="encoding/EncodingUtils.js"></script>
+ <script type="text/javascript" src="../encoding/EncodingUtils.js"></script>
- <script type="text/javascript" src="lwNDN.js"></script>
+ <script type="text/javascript" src="../NDN.js"></script>
- <script language="JavaScript" type="text/javascript" src="security/KeyManager.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../security/KeyManager.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/jsbn.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/jsbn2.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/rsa.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/rsa2.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/jsbn.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/jsbn2.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/rsa.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/rsa2.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/sha1.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/sha256.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/sha512.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/md5.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/ripemd160.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/base64.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/sha1.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/sha256.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/sha512.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/md5.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/ripemd160.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/base64.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/rsapem-1.1.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/rsasign-1.2.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/asn1hex-1.1.js"></script>
- <script language="JavaScript" type="text/javascript" src="securityLib/x509-1.1.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/rsapem-1.1.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/rsasign-1.2.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/asn1hex-1.1.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/x509-1.1.js"></script>
<script type="text/javascript">
@@ -82,7 +82,7 @@
var LOG = 0;
function init(){
- connector = new lwNDN('127.0.0.1', 9695);
+ connector = new NDN();
}
function run(){
@@ -105,7 +105,7 @@
//content object
//var co = queryPrefix( Name );
- var connector = new lwNDN('127.0.0.1', 9695);
+ var connector = new NDN();
var co = connector.put( ContentName, Content );
@@ -153,7 +153,7 @@
<button onclick="publishImage()">Publish image</button>
</div>
<div >
- <applet id="JavaSocketBridge" archive="JavaSocketBridge.jar" code="JavaSocketBridge.class" width="0" height="0">
+ <applet id="JavaSocketBridge" archive="../JavaSocketBridge.jar" code="JavaSocketBridge.class" width="0" height="0">
</applet>
</div>
diff --git a/js/testing/test-connection.html b/js/testing/test-connection.html
index 29a017a..2e04a64 100644
--- a/js/testing/test-connection.html
+++ b/js/testing/test-connection.html
@@ -4,7 +4,7 @@
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
- <title>Test Connect </title>
+ <title>Test Connection</title>
<script type="text/javascript" src="../java_socket_bridge.js"></script>
<script type="text/javascript" src="../CCNProtocolDTags.js"></script>
@@ -72,10 +72,11 @@
function getAction(){
console.log('ABOUT TO GET');
+ // Interest for "/"
+ var hex = '01d2f20000';
+ var received = get('127.0.0.1', 9695, hex);
- var received = get('127.0.0.1',9695,'01d2f2fafdc12e4d2e532e6c6f63616c686f737400fabdc12e4d2e53525600faa563636e6400fa9d4b4559000002d28e310000');
-
- output= '<br /> received Content '+received;
+ var output= '<br /> received Content: <br/>' + received;
console.log('INTEREST RECEIVED '+ received);
@@ -87,11 +88,14 @@
function putAction(){
console.log('ABOUT TO PUT');
- //var received = DataUtils.toString( DataUtils.toNumbers(send_test_interest()));
-
- var received = put('127.0.0.1',9695,'01d2f2faa563636e7800fa0285e0a01e093968f9740ce7f4361babf5bb05a4e55aaca5e58f73eddeb8e013aa8f00fabd73656c6672656700fa1bf5048202aa03b208854a18988c72aee624da28e2e1acbccb209b8e89429041985521ed68f95a1c546872fba3d854b1377dc249b6d8ec5935e5069256c97a7f6d8a62e86222ccd2cfe5097aed3fe5ede6732ce191a8680d78e39d0c5058a2b7bb0f0687994e9f045de346b66c46498547a08da1f2f0cdfafba3afdfe7107931935ede79040137ba94a90000f20001a203e202851a4860caa4991e829bcdc9429fb711d52440968d23560726606050bf147acffc0002bab504fcb3f03aa40001e201da0a9530819f300d06092a864886f70d010101050003818d00308189028181008ed27580e3d1c4c67672208665133a1ba12d8ebf5cad8e054571926b3ff0782a04c71703384021a6cefb6616b66cbd8a679b761d69d6373a851546e26f7105510b4c23be9a3c7f2e652e100ecc1471855730659f1477ce4e8504ad1fd8f44116baaeae2ff67eec33abba790157a79bf5039e5a528a471d9d67c94e70117ed7490203010001000000019a0585058a04cabe73656c6672656700f2faad726f63636f000003e20285e0a01e093968f9740ce7f4361babf5bb05a4e55aaca5e58f73eddeb8e013aa8f0004fa8e330003d2d63231343734383336343700000000000002d28e310000');
+ var hex = '01d2f2faa563636e7800fa0285e0290233a1f9da00a6b0db63b910379f6d98edd2b5ea7b0044109923286e6aaa00fabd73656c6672656700fa1a95048202aa03b20885a4024a492e588eade1bb1f94c151a617a41dde3d571d94ea1ac9d3c77f4c9f0ed5700c9722b3497124f3003320e346a2dead367b92a53bb087298023b0ac15584d3dcfb51482b6f458f24d37d46095c97b708aacaabd3fdfa981a86bd4831b2596b1ac23faa3ac6dcf3cb324dea96bc3d75aee7f1d6178ed82a09d5f31c6fa800000f20001a203e20285b5506b1aba3da7761b0f8d61a4aa7e3b6d15b426feb5bda82389aca765a3b81c0002bab505068dba9ba20001e201da0a9530819f300d06092a864886f70d010101050003818d0030818902818100e17d30a7d828ab1b840b17542dcaf6207afd221e086b2a60d16cb7f54448ba9f3f08bcd099db21dd162a779e61aa89eee554d3a47de230bc7ac590d524067c3898bba6f5dc4360b845eda48cbd9cf126a723445f0e1952d7325a75faf556144f9a98af7186b0278685b8e2c08bea87171b4dee585c1828295b5395eb4a17779f0203010001000000019a03a5058a04cabe73656c6672656700f2faa564656d6f00fabd6d657373616765000004fa8e330003d2d63231343734383336343700000000000002d28e310000';
+ var name = '/demo/message';
+ // Signed content of "It works!".
+ outputHex = '048202aa03b20885c8762b14c1df125229ecc88ff5080d042a2de01cd0b8e4357af88cff993c0c78c9774ebaf00bebfa2699ae81412fe03a155291981f3c914f2bc075446bb3dafce0314a40bc4c93890c6663da80b7798b66d97be6ddbee58ca30761d28b46ce3ac058b1fbbab7fad981626de954c54c09d68ebb8a18d31a4e1fb970677fb43f180000f2faa564656d6f00fabd6d657373616765000001a203e20285b5506b1aba3da7761b0f8d61a4aa7e3b6d15b426feb5bda82389aca765a3b81c0002bab505068dbab1f00001e201da0a9530819f300d06092a864886f70d010101050003818d0030818902818100e17d30a7d828ab1b840b17542dcaf6207afd221e086b2a60d16cb7f54448ba9f3f08bcd099db21dd162a779e61aa89eee554d3a47de230bc7ac590d524067c3898bba6f5dc4360b845eda48cbd9cf126a723445f0e1952d7325a75faf556144f9a98af7186b0278685b8e2c08bea87171b4dee585c1828295b5395eb4a17779f0203010001000000019add5468697320776f726b73210000';
+
+ var received = put('127.0.0.1', 9695, hex, name, outputHex);
- output= '<br /> received Content '+received;
+ var output= '<br /> received Content: <br/>' + received;
document.getElementById('result').innerHTML = output;
diff --git a/js/testing/test-get.html b/js/testing/test-get.html
index 780b5be..c17e310 100644
--- a/js/testing/test-get.html
+++ b/js/testing/test-get.html
@@ -7,6 +7,8 @@
<title>NDN Get</title>
<script type="text/javascript" src="../java_socket_bridge.js"></script>
+ <script type="text/javascript" src="../NDN.js"></script>
+
<script type="text/javascript" src="../CCNProtocolDTags.js"></script>
<script type="text/javascript" src="../CCNTime.js"></script>
@@ -49,7 +51,7 @@
<script type="text/javascript" src="../encoding/DataUtils.js"></script>
<script type="text/javascript" src="../encoding/EncodingUtils.js"></script>
-
+
<script language="JavaScript" type="text/javascript" src="../security/KeyManager.js"></script>
<script language="JavaScript" type="text/javascript" src="../securityLib/jsbn.js"></script>
@@ -72,13 +74,10 @@
<script type="text/javascript">
function getAction(){
- var interest = new Interest( new Name(document.getElementById('interest').value));
- interest.scope = 1;
-
- var received = get('127.0.0.1', 9695, encodeToHexInterest(interest));
+ var connector = new NDN();
+ var co = connector.get(document.getElementById('interest').value);
- output = '<br /> received Content ' + received + '<br />' + contentObjectToHtml(decodeHexContentObject(received));
- console.log('INTEREST RECEIVED '+ received);
+ var output = '<br/> received Content:<br/>' + contentObjectToHtml(co);
document.getElementById('result').innerHTML = output;
}
@@ -90,7 +89,7 @@
<form>
Please Enter an Interest:<br />
- <input id="interest" type="text" name="INTEREST" size="50" value="/ndn/ucla.edu/apps/lwndn-test/hello.txt" />
+ <input id="interest" type="text" name="INTEREST" size="50" value="/" />
</form>
<button onclick="getAction()">GET!</button>
diff --git a/js/testing/test-put.html b/js/testing/test-put.html
new file mode 100644
index 0000000..18567c1
--- /dev/null
+++ b/js/testing/test-put.html
@@ -0,0 +1,116 @@
+<?xml version = "1.0" encoding="utf-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+"DTD/xhtml1-strict.dtd">
+<html xmlns = "http://www.w3.org/1999/xhtml">
+
+<head>
+ <title>NDN Put</title>
+ <script type="text/javascript" src="../java_socket_bridge.js"></script>
+
+ <script type="text/javascript" src="../CCNProtocolDTags.js"></script>
+
+ <script type="text/javascript" src="../CCNTime.js"></script>
+
+ <script type="text/javascript" src="../Name.js"></script>
+
+ <script type="text/javascript" src="../ContentObject.js"></script>
+
+ <script type="text/javascript" src="../DateFormat.js"></script>
+
+ <script type="text/javascript" src="../Exclude.js"></script>
+
+ <script type="text/javascript" src="../ExcludeAny.js"></script>
+
+ <script type="text/javascript" src="../ExcludeComponent.js"></script>
+
+ <script type="text/javascript" src="../Interest.js"></script>
+
+ <script type="text/javascript" src="../KeyLocator.js"></script>
+
+ <script type="text/javascript" src="../PublisherID.js"></script>
+
+ <script type="text/javascript" src="../Signature.js"></script>
+
+ <script type="text/javascript" src="../SignedInfo.js"></script>
+
+ <script type="text/javascript" src="../PublisherPublicKeyDigest.js"></script>
+
+ <script type="text/javascript" src="../FaceInstance.js"></script>
+
+ <script type="text/javascript" src="../ForwardingEntry.js"></script>
+
+ <script type="text/javascript" src="../encoding/BinaryXMLEncoder.js"></script>
+
+ <script type="text/javascript" src="../encoding/BinaryXMLCodec.js"></script>
+
+ <script type="text/javascript" src="../encoding/BinaryXMLDecoder.js"></script>
+
+ <script type="text/javascript" src="../encoding/DataUtils.js"></script>
+
+ <script type="text/javascript" src="../encoding/EncodingUtils.js"></script>
+
+ <script type="text/javascript" src="../NDN.js"></script>
+
+
+ <script language="JavaScript" type="text/javascript" src="../security/KeyManager.js"></script>
+
+ <script language="JavaScript" type="text/javascript" src="../securityLib/jsbn.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/jsbn2.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/rsa.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/rsa2.js"></script>
+
+ <script language="JavaScript" type="text/javascript" src="../securityLib/sha1.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/sha256.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/sha512.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/md5.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/ripemd160.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/base64.js"></script>
+
+ <script language="JavaScript" type="text/javascript" src="../securityLib/rsapem-1.1.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/rsasign-1.2.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/asn1hex-1.1.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/x509-1.1.js"></script>
+
+
+ <script type="text/javascript">
+ function run(){
+ var contentName = document.getElementById('contentname').value;
+ var content = document.getElementById('content').value;
+
+ var connector = new NDN();
+ var result = connector.put( contentName, content );
+
+ document.getElementById('result').innerHTML = 'Content \'' + content +
+ '\' was published with content name \'' + contentName +'\'. Result:<br/>' +
+ result;
+ }
+
+ </script>
+
+</head>
+<body >
+ <form>
+ <div>
+ <p>Please Enter a Content Name:</p>
+
+ <input id="contentname" type="text" name="CONTENTNAME" value="/demo/message" />
+
+ <p>Please Enter the Content:</p>
+
+ <textarea id="content" cols="40" rows="5" name="CONTENT" >This works!</textarea>
+
+ <br />
+ </div>
+ </form>
+ <div>
+ <button onclick="run()">PUT!</button>
+ </div>
+ <div >
+ <applet id="JavaSocketBridge" archive="../JavaSocketBridge.jar" code="JavaSocketBridge.class" width="0" height="0">
+ </applet>
+ </div>
+
+ <p id="result"></p>
+
+</body>
+</html>
\ No newline at end of file