blob: c156af19d41999343a7d161350edb6aa1552231b [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
Meki Cherkaouif3d8f692012-05-18 15:44:28 -070023 if(LOG>4) console.log('KEY NAME FOUND: ');
24
Meki Cherkaoui8f173612012-06-06 01:05:40 -070025 if ( PublisherID.peek(decoder) ) {
Meki Cherkaouif441d3a2012-04-22 15:17:52 -070026 this.PublisherID = new PublisherID();
27 this.PublisherID.decode(decoder);
28 }
29
30 decoder.readEndElement();
31};
32
33KeyName.prototype.encode = function( encoder) {
34 if (!this.validate()) {
35 throw new Exception("Cannot encode : field values missing.");
36 }
37
38 encoder.writeStartElement(this.getElementLabel());
39
40 this.ContentName.encode(encoder);
41 if (null != this.PublisherID)
42 this.PublisherID.encode(encoder);
43
44 encoder.writeEndElement();
45};
46
47KeyName.prototype.getElementLabel = function() { return CCNProtocolDTags.KeyName; };
48
49KeyName.prototype.validate = function() {
50 // DKS -- do we do recursive validation?
51 // null signedInfo ok
52 return (null != this.ContentName);
53};