blob: 036a550fe8a0c44d0afec0b0fd9ffb803222d095 [file] [log] [blame]
Meki Cherkaouif441d3a2012-04-22 15:17:52 -07001/*
2 * @author: ucla-cs
3 * This class represents KeyName Objects
4 */
5
6var KeyName = function KeyName() {
7
8
9 this.ContentName = this.ContentName;//ContentName
10 this.PublisherID =this.PublisherID;//PublisherID
11
12};
13
14
15KeyName.prototype.decode=function( decoder){
16
17
18 decoder.readStartElement(this.getElementLabel());
19
20 this.ContentName = new ContentName();
21 this.ContentName.decode(decoder);
22
23 if ( peek(decoder) ) {
24 this.PublisherID = new PublisherID();
25 this.PublisherID.decode(decoder);
26 }
27
28 decoder.readEndElement();
29};
30
31KeyName.prototype.encode = function( encoder) {
32 if (!this.validate()) {
33 throw new Exception("Cannot encode : field values missing.");
34 }
35
36 encoder.writeStartElement(this.getElementLabel());
37
38 this.ContentName.encode(encoder);
39 if (null != this.PublisherID)
40 this.PublisherID.encode(encoder);
41
42 encoder.writeEndElement();
43};
44
45KeyName.prototype.getElementLabel = function() { return CCNProtocolDTags.KeyName; };
46
47KeyName.prototype.validate = function() {
48 // DKS -- do we do recursive validation?
49 // null signedInfo ok
50 return (null != this.ContentName);
51};