blob: cadf1e7e63ddcdc7aa1a5ef198f80f2db73a3912 [file] [log] [blame]
Alexander Afanasyevfce5bbd2013-08-07 18:50:00 -07001## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2#
3# Copyright (c) 2011-2013, Regents of the University of California
4# Alexander Afanasyev
5#
6# GNU 3.0 license, See the LICENSE file for more information
7#
8# Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
9#
10
11#
12# Based on PyCCN code, copyrighted and licensed as follows
13#
14# Copyright (c) 2011-2013, Regents of the University of California
15# BSD license, See the COPYING file for more information
16# Written by: Derek Kulinski <takeda@takeda.tk>
17# Jeff Burke <jburke@ucla.edu>
18#
19
20import utils
21
22class ContentType(utils.Enum):
23 _prefix = "ndn"
24
25CONTENT_DATA = ContentType.new_flag('CONTENT_DATA', 0x0C04C0)
26CONTENT_ENCR = ContentType.new_flag('CONTENT_ENCR', 0x10D091)
27CONTENT_GONE = ContentType.new_flag('CONTENT_GONE', 0x18E344)
28CONTENT_KEY = ContentType.new_flag('CONTENT_KEY', 0x28463F)
29CONTENT_LINK = ContentType.new_flag('CONTENT_LINK', 0x2C834A)
30CONTENT_NACK = ContentType.new_flag('CONTENT_NACK', 0x34008A)
31
32class SignedInfo (object):
33 def __init__(self, keyLocator = None, freshness = None, timestamp = None, type = CONTENT_DATA):
34
35 self.timestamp = timestamp
36 self.freshnessSeconds = freshness
37 self.keyLocator = keyLocator
38 self.type = type
39
40 def __repr__(self):
41 args = []
42
43 if self.keyLocator is not None:
44 args += ["keyLocator=%r" % self.keyLocator]
45 if self.freshnessSeconds is not None:
46 args += ["freshness=%r" % self.freshnessSeconds]
Alexander Afanasyev40bc46d2013-08-08 01:27:12 -070047 if self.timestamp is not None:
Alexander Afanasyevfce5bbd2013-08-07 18:50:00 -070048 args += ["timestamp=%r" % self.timestamp]
49 if self.type != CONTENT_DATA:
50 args += ["type=%r" % self.type]
51
52 return "ndn.SignedInfo(%s)" % ", ".join(args)
53