Major update: Refactor to rename ContentName to Name. Delete KeyName.js. For the moment, the KeyName class is now in KeyLocator.js.
This is done according to the API notes:
http://sea.remap.ucla.edu:8080/attachments/download/23/lwndn_api-notes_21020830.txt
diff --git a/js/ContentObject.js b/js/ContentObject.js
index eb5db79..8caa2df 100644
--- a/js/ContentObject.js
+++ b/js/ContentObject.js
@@ -6,7 +6,7 @@
if (typeof _name === 'string'){
- this.name = new ContentName(_name);
+ this.name = new Name(_name);
}
else{
//TODO Check the class of _name
@@ -110,7 +110,7 @@
this.startSIG = decoder.offset;
- this.name = new ContentName();
+ this.name = new Name();
this.name.from_ccnb(decoder);
//this.startSignedInfo = decoder.offset;
diff --git a/js/ForwardingEntry.js b/js/ForwardingEntry.js
index 4f04478..f0314d7 100644
--- a/js/ForwardingEntry.js
+++ b/js/ForwardingEntry.js
@@ -6,7 +6,7 @@
var ForwardingEntry = function ForwardingEntry(
//ActionType
_action,
- //ContentName
+ //Name
_prefixName,
//PublisherPublicKeyDigest
_ccndId,
@@ -21,7 +21,7 @@
//String
this.action = _action;
- //ContentName\
+ //Name\
this.prefixName = _prefixName;
//PublisherPublicKeyDigest
this.ccndID = _ccndId;
@@ -44,7 +44,7 @@
this.action = decoder.readUTF8Element(CCNProtocolDTags.Action);
}
if (decoder.peekStartElement(CCNProtocolDTags.Name)) {
- this.prefixName = new ContentName();
+ this.prefixName = new Name();
this.prefixName.from_ccnb(decoder) ;
}
if (decoder.peekStartElement(CCNProtocolDTags.PublisherPublicKeyDigest)) {
diff --git a/js/Interest.js b/js/Interest.js
index 15fb05a..04cc290 100644
--- a/js/Interest.js
+++ b/js/Interest.js
@@ -36,7 +36,7 @@
decoder.readStartElement(CCNProtocolDTags.Interest);
- this.name = new ContentName();
+ this.name = new Name();
this.name.from_ccnb(decoder);
if (decoder.peekStartElement(CCNProtocolDTags.MinSuffixComponents)) {
@@ -117,7 +117,7 @@
};
-Interest.prototype.matches_name = function(/*ContentName*/ name){
+Interest.prototype.matches_name = function(/*Name*/ name){
var i_name = this.name.components;
var o_name = name.components;
diff --git a/js/KeyLocator.js b/js/KeyLocator.js
index 14f283c..0a73cb5 100644
--- a/js/KeyLocator.js
+++ b/js/KeyLocator.js
@@ -126,4 +126,54 @@
KeyLocator.prototype.validate = function() {
return ( (null != this.keyName) || (null != this.publicKey) || (null != this.certificate) );
};
-
\ No newline at end of file
+
+/**
+ * KeyName is only used by KeyLocator.
+ */
+var KeyName = function KeyName() {
+
+
+ this.contentName = this.contentName;//contentName
+ this.publisherID =this.publisherID;//publisherID
+
+};
+
+KeyName.prototype.from_ccnb=function( decoder){
+
+
+ decoder.readStartElement(this.getElementLabel());
+
+ this.contentName = new Name();
+ this.contentName.from_ccnb(decoder);
+
+ if(LOG>4) console.log('KEY NAME FOUND: ');
+
+ if ( PublisherID.peek(decoder) ) {
+ this.publisherID = new PublisherID();
+ this.publisherID.from_ccnb(decoder);
+ }
+
+ decoder.readEndElement();
+};
+
+KeyName.prototype.to_ccnb = function( encoder) {
+ if (!this.validate()) {
+ throw new Error("Cannot encode : field values missing.");
+ }
+
+ encoder.writeStartElement(this.getElementLabel());
+
+ this.contentName.to_ccnb(encoder);
+ if (null != this.publisherID)
+ this.publisherID.to_ccnb(encoder);
+
+ encoder.writeEndElement();
+};
+
+KeyName.prototype.getElementLabel = function() { return CCNProtocolDTags.KeyName; };
+
+KeyName.prototype.validate = function() {
+ // DKS -- do we do recursive validation?
+ // null signedInfo ok
+ return (null != this.contentName);
+};
diff --git a/js/KeyName.js b/js/KeyName.js
deleted file mode 100644
index ccbda2a..0000000
--- a/js/KeyName.js
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * @author: ucla-cs
- * This class represents KeyName Objects
- */
-
-var KeyName = function KeyName() {
-
-
- this.contentName = this.contentName;//contentName
- this.publisherID =this.publisherID;//publisherID
-
-};
-
-
-KeyName.prototype.from_ccnb=function( decoder){
-
-
- decoder.readStartElement(this.getElementLabel());
-
- this.contentName = new ContentName();
- this.contentName.from_ccnb(decoder);
-
- if(LOG>4) console.log('KEY NAME FOUND: ');
-
- if ( PublisherID.peek(decoder) ) {
- this.publisherID = new PublisherID();
- this.publisherID.from_ccnb(decoder);
- }
-
- decoder.readEndElement();
-};
-
-KeyName.prototype.to_ccnb = function( encoder) {
- if (!this.validate()) {
- throw new Error("Cannot encode : field values missing.");
- }
-
- encoder.writeStartElement(this.getElementLabel());
-
- this.contentName.to_ccnb(encoder);
- if (null != this.publisherID)
- this.publisherID.to_ccnb(encoder);
-
- encoder.writeEndElement();
-};
-
-KeyName.prototype.getElementLabel = function() { return CCNProtocolDTags.KeyName; };
-
-KeyName.prototype.validate = function() {
- // DKS -- do we do recursive validation?
- // null signedInfo ok
- return (null != this.contentName);
-};
diff --git a/js/ContentName.js b/js/Name.js
similarity index 75%
rename from js/ContentName.js
rename to js/Name.js
index d0d7711..69e3098 100644
--- a/js/ContentName.js
+++ b/js/Name.js
@@ -1,20 +1,20 @@
/*
* @author: ucla-cs
- * This class represents ContentName
+ * This class represents a Name
*/
-var ContentName = function ContentName(_components){
+var Name = function Name(_components){
if( typeof _components == 'string') {
if(LOG>3)console.log('Content Name String '+_components);
- this.components = ContentName.makeBlob(ContentName.createNameArray(_components));
+ this.components = Name.makeBlob(Name.createNameArray(_components));
}
else if(typeof _components === 'object' && _components instanceof Array ){
if(LOG>4)console.log('Content Name Array '+_components);
- this.components = ContentName.makeBlob(_components);
+ this.components = Name.makeBlob(_components);
}
else if(_components==null){
@@ -27,7 +27,7 @@
}
};
-ContentName.prototype.getName=function(){
+Name.prototype.getName=function(){
var output = "";
@@ -39,7 +39,7 @@
};
-ContentName.makeBlob=function(name){
+Name.makeBlob=function(name){
var blobArrays = new Array(name.length);
@@ -55,7 +55,7 @@
return blobArrays;
};
-ContentName.createNameArray=function(name){
+Name.createNameArray=function(name){
name = unescape(name);
@@ -73,7 +73,7 @@
}
-ContentName.prototype.from_ccnb = function(/*XMLDecoder*/ decoder) {
+Name.prototype.from_ccnb = function(/*XMLDecoder*/ decoder) {
decoder.readStartElement(this.getElementLabel());
@@ -86,7 +86,7 @@
decoder.readEndElement();
};
-ContentName.prototype.to_ccnb = function(/*XMLEncoder*/ encoder) {
+Name.prototype.to_ccnb = function(/*XMLEncoder*/ encoder) {
if( this.components ==null )
throw new Error("CANNOT ENCODE EMPTY CONTENT NAME");
@@ -99,11 +99,11 @@
encoder.writeEndElement();
};
-ContentName.prototype.getElementLabel = function(){
+Name.prototype.getElementLabel = function(){
return CCNProtocolDTags.Name;
};
-ContentName.prototype.add = function(param){
+Name.prototype.add = function(param){
return this.components.push(param);
};
diff --git a/js/image-loader.html b/js/image-loader.html
index b6740bf..3fe6442 100644
--- a/js/image-loader.html
+++ b/js/image-loader.html
@@ -11,7 +11,7 @@
<script type="text/javascript" src="CCNTime.js"></script>
- <script type="text/javascript" src="ContentName.js"></script>
+ <script type="text/javascript" src="Name.js"></script>
<script type="text/javascript" src="ContentObject.js"></script>
@@ -27,8 +27,6 @@
<script type="text/javascript" src="KeyLocator.js"></script>
- <script type="text/javascript" src="KeyName.js"></script>
-
<script type="text/javascript" src="PublisherID.js"></script>
<script type="text/javascript" src="Signature.js"></script>
diff --git a/js/image-sender.html b/js/image-sender.html
index 9990909..14fc8fb 100644
--- a/js/image-sender.html
+++ b/js/image-sender.html
@@ -11,7 +11,7 @@
<script type="text/javascript" src="CCNTime.js"></script>
- <script type="text/javascript" src="ContentName.js"></script>
+ <script type="text/javascript" src="Name.js"></script>
<script type="text/javascript" src="ContentObject.js"></script>
@@ -27,8 +27,6 @@
<script type="text/javascript" src="KeyLocator.js"></script>
- <script type="text/javascript" src="KeyName.js"></script>
-
<script type="text/javascript" src="PublisherID.js"></script>
<script type="text/javascript" src="Signature.js"></script>
@@ -105,7 +103,7 @@
//createRoute('borges.metwi.ucla.edu', 9695);
//content object
- //var co = queryPrefix( ContentName );
+ //var co = queryPrefix( Name );
var connector = new lwNDN('127.0.0.1', 9695);
@@ -143,7 +141,7 @@
var Content = imageString.substr(beginning, length);
console.log(beginning + "; " + length);
var co = connector.put(ContentName, Content);
- //document.getElementById('result').innerHTML += 'Content \'' + Content + '\' was published with content name \'' + ContentName +'\'';
+ //document.getElementById('result').innerHTML += 'Content \'' + Content + '\' was published with content name \'' + Name +'\'';
}
diff --git a/js/java_socket_bridge.js b/js/java_socket_bridge.js
index 68c2e9e..5f617b6 100644
--- a/js/java_socket_bridge.js
+++ b/js/java_socket_bridge.js
@@ -72,7 +72,7 @@
var answer = toNumbersFromString('WORLD');
- var co = new ContentObject(new ContentName(name),si,answer,new Signature());
+ var co = new ContentObject(new Name(name),si,answer,new Signature());
co.sign();
diff --git a/js/lwNDN.js b/js/lwNDN.js
index c6658cd..25615fb 100644
--- a/js/lwNDN.js
+++ b/js/lwNDN.js
@@ -20,9 +20,9 @@
}
- //var array = ContentName.createNameArray(message);
+ //var array = Name.createNameArray(message);
- int = new Interest(new ContentName(message));
+ int = new Interest(new Name(message));
int.InterestLifetime = 4200;
@@ -80,7 +80,7 @@
name = name.trim();
- var fe = new ForwardingEntry('selfreg',new ContentName(name),null, null, 3,2147483647);
+ var fe = new ForwardingEntry('selfreg',new Name(name),null, null, 3,2147483647);
var bytes = encodeForwardingEntry(fe);
@@ -88,14 +88,14 @@
var si = new SignedInfo();
si.setFields();
- var co = new ContentObject(new ContentName(),si,bytes,new Signature());
+ var co = new ContentObject(new Name(),si,bytes,new Signature());
co.sign();
var coBinary = encodeToBinaryContentObject(co);
//var ccnxnodename = unescape('%E0%A0%1E%099h%F9t%0C%E7%F46%1B%AB%F5%BB%05%A4%E5Z%AC%A5%E5%8Fs%ED%DE%B8%E0%13%AA%8F');
- var interestName = new ContentName(['ccnx',ccnxnodename,'selfreg',coBinary]);
+ var interestName = new Name(['ccnx',ccnxnodename,'selfreg',coBinary]);
int = new Interest(interestName);
int.scope = 1;
@@ -125,7 +125,7 @@
var answer = DataUtils.toNumbersFromString(content);
- var co = new ContentObject(new ContentName(name),si,answer,new Signature());
+ var co = new ContentObject(new Name(name),si,answer,new Signature());
co.sign();
diff --git a/js/publish-data.html b/js/publish-data.html
index e2574eb..d396452 100644
--- a/js/publish-data.html
+++ b/js/publish-data.html
@@ -11,7 +11,7 @@
<script type="text/javascript" src="CCNTime.js"></script>
- <script type="text/javascript" src="ContentName.js"></script>
+ <script type="text/javascript" src="Name.js"></script>
<script type="text/javascript" src="ContentObject.js"></script>
@@ -27,8 +27,6 @@
<script type="text/javascript" src="KeyLocator.js"></script>
- <script type="text/javascript" src="KeyName.js"></script>
-
<script type="text/javascript" src="PublisherID.js"></script>
<script type="text/javascript" src="Signature.js"></script>
@@ -93,7 +91,7 @@
//createRoute('borges.metwi.ucla.edu', 9695);
//content object
- //var co = queryPrefix( ContentName );
+ //var co = queryPrefix( Name );
var connector = new lwNDN('127.0.0.1', 9695);
//var connector = new lwNDN('131.179.141.15', 9695);
diff --git a/js/request-data.html b/js/request-data.html
index 5b7e0ab..9fb6a4f 100644
--- a/js/request-data.html
+++ b/js/request-data.html
@@ -11,7 +11,7 @@
<script type="text/javascript" src="CCNTime.js"></script>
- <script type="text/javascript" src="ContentName.js"></script>
+ <script type="text/javascript" src="Name.js"></script>
<script type="text/javascript" src="ContentObject.js"></script>
@@ -27,8 +27,6 @@
<script type="text/javascript" src="KeyLocator.js"></script>
- <script type="text/javascript" src="KeyName.js"></script>
-
<script type="text/javascript" src="PublisherID.js"></script>
<script type="text/javascript" src="Signature.js"></script>
diff --git a/js/testing/test-connection.html b/js/testing/test-connection.html
index eb0d137..29a017a 100644
--- a/js/testing/test-connection.html
+++ b/js/testing/test-connection.html
@@ -11,7 +11,7 @@
<script type="text/javascript" src="../CCNTime.js"></script>
- <script type="text/javascript" src="../ContentName.js"></script>
+ <script type="text/javascript" src="../Name.js"></script>
<script type="text/javascript" src="../ContentObject.js"></script>
@@ -27,8 +27,6 @@
<script type="text/javascript" src="../KeyLocator.js"></script>
- <script type="text/javascript" src="../KeyName.js"></script>
-
<script type="text/javascript" src="../PublisherID.js"></script>
<script type="text/javascript" src="../Signature.js"></script>
diff --git a/js/testing/test-decode-FaceInstance.html b/js/testing/test-decode-FaceInstance.html
index 196afbe..999e5f2 100644
--- a/js/testing/test-decode-FaceInstance.html
+++ b/js/testing/test-decode-FaceInstance.html
@@ -12,7 +12,7 @@
<script type="text/javascript" src="../CCNTime.js"></script>
- <script type="text/javascript" src="../ContentName.js"></script>
+ <script type="text/javascript" src="../Name.js"></script>
<script type="text/javascript" src="../ContentObject.js"></script>
@@ -28,8 +28,6 @@
<script type="text/javascript" src="../KeyLocator.js"></script>
- <script type="text/javascript" src="../KeyName.js"></script>
-
<script type="text/javascript" src="../PublisherID.js"></script>
<script type="text/javascript" src="../Signature.js"></script>
@@ -154,7 +152,7 @@
<body >
<form>
- Please Enter a Interest:<br />
+ Please Press Decode:<br />
<!-- input id="faceInstance" type="text" name="FACEINSTANCE" value="/PARC/abc" /-->
diff --git a/js/testing/test-decode-Interest+Forwarding+Entry.html b/js/testing/test-decode-Interest+Forwarding+Entry.html
index 5e5e1c0..362b254 100644
--- a/js/testing/test-decode-Interest+Forwarding+Entry.html
+++ b/js/testing/test-decode-Interest+Forwarding+Entry.html
@@ -12,7 +12,7 @@
<script type="text/javascript" src="../CCNTime.js"></script>
- <script type="text/javascript" src="../ContentName.js"></script>
+ <script type="text/javascript" src="../Name.js"></script>
<script type="text/javascript" src="../ContentObject.js"></script>
@@ -28,8 +28,6 @@
<script type="text/javascript" src="../KeyLocator.js"></script>
- <script type="text/javascript" src="../KeyName.js"></script>
-
<script type="text/javascript" src="../PublisherID.js"></script>
<script type="text/javascript" src="../Signature.js"></script>
diff --git a/js/testing/test-encode-decode-ContentObject-bis.html b/js/testing/test-encode-decode-ContentObject-bis.html
index 6e8dad9..8ea3e93 100644
--- a/js/testing/test-encode-decode-ContentObject-bis.html
+++ b/js/testing/test-encode-decode-ContentObject-bis.html
@@ -12,7 +12,7 @@
<script type="text/javascript" src="../CCNTime.js"></script>
- <script type="text/javascript" src="../ContentName.js"></script>
+ <script type="text/javascript" src="../Name.js"></script>
<script type="text/javascript" src="../ContentObject.js"></script>
@@ -28,8 +28,6 @@
<script type="text/javascript" src="../KeyLocator.js"></script>
- <script type="text/javascript" src="../KeyName.js"></script>
-
<script type="text/javascript" src="../PublisherID.js"></script>
<script type="text/javascript" src="../Signature.js"></script>
@@ -72,7 +70,7 @@
<script type="text/javascript">
function encode(){
- var contentname = new ContentName( createNameArray(document.getElementById('contentname').value) );
+ var contentname = new Name( createNameArray(document.getElementById('contentname').value) );
var content = document.getElementById('content').value;
diff --git a/js/testing/test-encode-decode-ContentObject.html b/js/testing/test-encode-decode-ContentObject.html
index 6818a86..08904c8 100644
--- a/js/testing/test-encode-decode-ContentObject.html
+++ b/js/testing/test-encode-decode-ContentObject.html
@@ -12,7 +12,7 @@
<script type="text/javascript" src="../CCNTime.js"></script>
- <script type="text/javascript" src="../ContentName.js"></script>
+ <script type="text/javascript" src="../Name.js"></script>
<script type="text/javascript" src="../ContentObject.js"></script>
@@ -26,8 +26,6 @@
<script type="text/javascript" src="../KeyLocator.js"></script>
- <script type="text/javascript" src="../KeyName.js"></script>
-
<script type="text/javascript" src="../PublisherID.js"></script>
<script type="text/javascript" src="../Signature.js"></script>
@@ -72,7 +70,7 @@
<script type="text/javascript">
function encode(){
- var contentname = new ContentName( document.getElementById('contentname').value );
+ var contentname = new Name( document.getElementById('contentname').value );
var content = document.getElementById('content').value;
diff --git a/js/testing/test-encode-decode-Interest.html b/js/testing/test-encode-decode-Interest.html
index d957176..ef69d67 100644
--- a/js/testing/test-encode-decode-Interest.html
+++ b/js/testing/test-encode-decode-Interest.html
@@ -12,7 +12,7 @@
<script type="text/javascript" src="../CCNTime.js"></script>
- <script type="text/javascript" src="../ContentName.js"></script>
+ <script type="text/javascript" src="../Name.js"></script>
<script type="text/javascript" src="../ContentObject.js"></script>
@@ -28,8 +28,6 @@
<script type="text/javascript" src="../KeyLocator.js"></script>
- <script type="text/javascript" src="../KeyName.js"></script>
-
<script type="text/javascript" src="../PublisherID.js"></script>
<script type="text/javascript" src="../Signature.js"></script>
@@ -74,7 +72,7 @@
<script type="text/javascript">
function encode(){
- var interest = new Interest( new ContentName(document.getElementById('interest').value ) );
+ var interest = new Interest( new Name(document.getElementById('interest').value ) );
interest.scope = 1;
diff --git a/js/testing/test-get.html b/js/testing/test-get.html
index 8053655..780b5be 100644
--- a/js/testing/test-get.html
+++ b/js/testing/test-get.html
@@ -11,7 +11,7 @@
<script type="text/javascript" src="../CCNTime.js"></script>
- <script type="text/javascript" src="../ContentName.js"></script>
+ <script type="text/javascript" src="../Name.js"></script>
<script type="text/javascript" src="../ContentObject.js"></script>
@@ -27,8 +27,6 @@
<script type="text/javascript" src="../KeyLocator.js"></script>
- <script type="text/javascript" src="../KeyName.js"></script>
-
<script type="text/javascript" src="../PublisherID.js"></script>
<script type="text/javascript" src="../Signature.js"></script>
@@ -74,7 +72,7 @@
<script type="text/javascript">
function getAction(){
- var interest = new Interest( new ContentName(document.getElementById('interest').value));
+ var interest = new Interest( new Name(document.getElementById('interest').value));
interest.scope = 1;
var received = get('127.0.0.1', 9695, encodeToHexInterest(interest));
diff --git a/js/testing/test-interest-matches-name.html b/js/testing/test-interest-matches-name.html
index 111789f..9038369 100644
--- a/js/testing/test-interest-matches-name.html
+++ b/js/testing/test-interest-matches-name.html
@@ -12,7 +12,7 @@
<script type="text/javascript" src="../CCNTime.js"></script>
- <script type="text/javascript" src="../ContentName.js"></script>
+ <script type="text/javascript" src="../Name.js"></script>
<script type="text/javascript" src="../ContentObject.js"></script>
@@ -28,8 +28,6 @@
<script type="text/javascript" src="../KeyLocator.js"></script>
- <script type="text/javascript" src="../KeyName.js"></script>
-
<script type="text/javascript" src="../PublisherID.js"></script>
<script type="text/javascript" src="../Signature.js"></script>
@@ -74,10 +72,10 @@
<script type="text/javascript">
function check(){
- var interest = new Interest( new ContentName(document.getElementById('interest').value));
+ var interest = new Interest( new Name(document.getElementById('interest').value));
interest.scope = 1;
- var nameToCheck = new ContentName(document.getElementById('nameToCheck').value);
+ var nameToCheck = new Name(document.getElementById('nameToCheck').value);
var output = (interest.matches_name(nameToCheck) ? "matches" : "doesn't match");
document.getElementById('result').innerHTML = output;
diff --git a/js/testing/test-request-send-hex.html b/js/testing/test-request-send-hex.html
index 3ed1a90..666d3f5 100644
--- a/js/testing/test-request-send-hex.html
+++ b/js/testing/test-request-send-hex.html
@@ -11,7 +11,7 @@
<script type="text/javascript" src="../CCNTime.js"></script>
- <script type="text/javascript" src="../ContentName.js"></script>
+ <script type="text/javascript" src="../Name.js"></script>
<script type="text/javascript" src="../ContentObject.js"></script>
@@ -27,8 +27,6 @@
<script type="text/javascript" src="../KeyLocator.js"></script>
- <script type="text/javascript" src="../KeyName.js"></script>
-
<script type="text/javascript" src="../PublisherID.js"></script>
<script type="text/javascript" src="../Signature.js"></script>
@@ -88,7 +86,7 @@
//createRoute('borges.metwi.ucla.edu', 9695);
//content object
- //var co = queryPrefix( ContentName );
+ //var co = queryPrefix( Name );
console.log('HEX IS');
console.log(hex);