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