blob: f60c6494d81008ebb0b735e82beeccac4e6d4582 [file] [log] [blame]
Meki Cherkaoui97e7a592012-04-14 02:50:06 -07001
2var PublisherPublicKeyDigest = function PublisherPublicKeyDigest(_pkd){
3
4 if( typeof _pkd == "ByteArray") this.PublisherPublicKeyDigest = _pkd; // Byte Array
5 else if( typeof _pkd == "PublicKey") ;//TODO...
6
7};
8
9PublisherPublicKeyDigest.prototype.decode = function( decoder) {
10
11 this.PublisherPublicKeyDigest = decoder.readBinaryElement(this.getElementLabel());
12 if (null == this.PublisherPublicKeyDigest) {
13 throw new Exception("Cannot parse publisher key digest.");
14 }
15 /*if (this.PublisherPublicKeyDigest.length != PublisherID.PUBLISHER_ID_LEN) {
16 console.log('SHOULD NOT GO HERE !!!!!!!!!!!!!!!!!!');
17 this.PublisherPublicKeyDigest = new PublisherPublicKeyDigest(this.PublisherPublicKeyDigest).PublisherKeyDigest;
18 }*/
19 };
20
21PublisherPublicKeyDigest.prototype.encode= function( encoder) {
22 /*if (!this.validate()) {
23 throw new Exception("Cannot encode : field values missing.");
24 }*/
25 if (this.PublisherKeyDigest!=null)this.encoder.writeElement(this.getElementLabel(), this.PublisherKeyDigest);
26};
27
28PublisherPublicKeyDigest.prototype.getElementLabel = function() { return CCNProtocolDTags.PublisherPublicKeyDigest; };
29
30PublisherPublicKeyDigest.prototype.validate =function() {
31 return (null != this.PublisherKeyDigest);
32};