Meki Cherkaoui | 97e7a59 | 2012-04-14 02:50:06 -0700 | [diff] [blame^] | 1 | |
| 2 | var 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 | |
| 9 | PublisherPublicKeyDigest.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 | |
| 21 | PublisherPublicKeyDigest.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 | |
| 28 | PublisherPublicKeyDigest.prototype.getElementLabel = function() { return CCNProtocolDTags.PublisherPublicKeyDigest; }; |
| 29 | |
| 30 | PublisherPublicKeyDigest.prototype.validate =function() { |
| 31 | return (null != this.PublisherKeyDigest); |
| 32 | }; |