blob: 84941ad61b69370b32a9c77f4d5290ebd2e2e1a8 [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):
Alexander Afanasyev05d40942013-08-09 12:43:26 -070033 def __init__(self, keyLocator = None, freshness = None,
34 timestamp = None, type = CONTENT_DATA, *kw, **kwargs):
Alexander Afanasyevfce5bbd2013-08-07 18:50:00 -070035
36 self.timestamp = timestamp
37 self.freshnessSeconds = freshness
38 self.keyLocator = keyLocator
39 self.type = type
40
Alexander Afanasyev05d40942013-08-09 12:43:26 -070041 # all other parameters are silently ignored
42
Alexander Afanasyevfce5bbd2013-08-07 18:50:00 -070043 def __repr__(self):
44 args = []
45
46 if self.keyLocator is not None:
47 args += ["keyLocator=%r" % self.keyLocator]
48 if self.freshnessSeconds is not None:
49 args += ["freshness=%r" % self.freshnessSeconds]
Alexander Afanasyev40bc46d2013-08-08 01:27:12 -070050 if self.timestamp is not None:
Alexander Afanasyevfce5bbd2013-08-07 18:50:00 -070051 args += ["timestamp=%r" % self.timestamp]
52 if self.type != CONTENT_DATA:
53 args += ["type=%r" % self.type]
54
55 return "ndn.SignedInfo(%s)" % ", ".join(args)
56