First Commit after cleanup
Socket Bridge in java now works with UDP
Now connecting to remote ccnd nodes ( unless there is a firewall on the
way) currently connecting to borges on port 9695
Cleaned up the code and added authors to all files since new people are
joining the project.
Separated java from javascript code.
diff --git a/js/PublisherID.js b/js/PublisherID.js
new file mode 100644
index 0000000..1e24cc7
--- /dev/null
+++ b/js/PublisherID.js
@@ -0,0 +1,97 @@
+/*
+ * @author: ucla-cs
+ * This class represents Publisher and PublisherType Objects
+ */
+
+
+var PublisherType = function PublisherType(_tag){
+ this.KEY =(CCNProtocolDTags.PublisherPublicKeyDigest);
+ this.CERTIFICATE= (CCNProtocolDTags.PublisherCertificateDigest);
+ this.ISSUER_KEY= (CCNProtocolDTags.PublisherIssuerKeyDigest);
+ this.ISSUER_CERTIFICATE =(CCNProtocolDTags.PublisherIssuerCertificateDigest);
+
+ this.Tag = _tag;
+};
+
+var isTypeTagVal = function(tagVal) {
+ if ((tagVal == CCNProtocolDTags.PublisherPublicKeyDigest) ||
+ (tagVal == CCNProtocolDTags.PublisherCertificateDigest) ||
+ (tagVal == CCNProtocolDTags.PublisherIssuerKeyDigest) ||
+ (tagVal == CCNProtocolDTags.PublisherIssuerCertificateDigest)) {
+ return true;
+ }
+ return false;
+};
+
+
+
+
+var PublisherID = function PublisherID() {
+
+ this.PUBLISHER_ID_DIGEST_ALGORITHM = "SHA-256";
+ this.PUBLISHER_ID_LEN = 256/8;
+
+ //TODO, implement publisherID creation and key creation
+
+ //TODO implement generatePublicKeyDigest
+ this.PublisherID =null;//= generatePublicKeyDigest(key);//ByteArray
+
+ //TODO implement generate key
+ //CryptoUtil.generateKeyID(PUBLISHER_ID_DIGEST_ALGORITHM, key);
+ this.PublisherType = null;//isIssuer ? PublisherType.ISSUER_KEY : PublisherType.KEY;//publisher Type
+
+};
+
+
+PublisherID.prototype.decode = function(decoder) {
+
+ // We have a choice here of one of 4 binary element types.
+ var nextTag = decoder.peekStartElementAsLong();
+
+ if (null == nextTag) {
+ throw new Exception("Cannot parse publisher ID.");
+ }
+
+ this.PublisherType = new PublisherType(nextTag);
+
+ if (!isTypeTagVal(nextTag)) {
+ throw new Exception("Invalid publisher ID, got unexpected type: " + nextTag);
+ }
+ this.PublisherID = decoder.readBinaryElement(nextTag);
+ if (null == this.PublisherID) {
+ throw new ContentDecodingException("Cannot parse publisher ID of type : " + nextTag + ".");
+ }
+};
+
+PublisherID.prototype.encode = function(encoder) {
+ if (!this.validate()) {
+ throw new Exception("Cannot encode " + this.getClass().getName() + ": field values missing.");
+ }
+
+ encoder.writeElement(this.getElementLabel(), this.PublisherID);
+};
+
+var peek = function(
+ //XMLDecoder
+ decoder) {
+
+ //Long
+ nextTag = decoder.peekStartElementAsLong();
+
+ if (null == nextTag) {
+ // on end element
+ return false;
+ }
+ return (isTypeTagVal(nextTag));
+ };
+
+PublisherID.prototype.getElementLabel = function() {
+ return this.PublisherType.Tag;
+};
+
+PublisherID.prototype.validate = function(){
+ return ((null != id() && (null != type())));
+};
+
+
+