Alexander Afanasyev | fce5bbd | 2013-08-07 18:50:00 -0700 | [diff] [blame] | 1 | ## -*- 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 | |
| 20 | import utils |
| 21 | |
| 22 | class ContentType(utils.Enum): |
| 23 | _prefix = "ndn" |
| 24 | |
| 25 | CONTENT_DATA = ContentType.new_flag('CONTENT_DATA', 0x0C04C0) |
| 26 | CONTENT_ENCR = ContentType.new_flag('CONTENT_ENCR', 0x10D091) |
| 27 | CONTENT_GONE = ContentType.new_flag('CONTENT_GONE', 0x18E344) |
| 28 | CONTENT_KEY = ContentType.new_flag('CONTENT_KEY', 0x28463F) |
| 29 | CONTENT_LINK = ContentType.new_flag('CONTENT_LINK', 0x2C834A) |
| 30 | CONTENT_NACK = ContentType.new_flag('CONTENT_NACK', 0x34008A) |
| 31 | |
| 32 | class SignedInfo (object): |
Alexander Afanasyev | 05d4094 | 2013-08-09 12:43:26 -0700 | [diff] [blame] | 33 | def __init__(self, keyLocator = None, freshness = None, |
| 34 | timestamp = None, type = CONTENT_DATA, *kw, **kwargs): |
Alexander Afanasyev | fce5bbd | 2013-08-07 18:50:00 -0700 | [diff] [blame] | 35 | |
| 36 | self.timestamp = timestamp |
| 37 | self.freshnessSeconds = freshness |
| 38 | self.keyLocator = keyLocator |
| 39 | self.type = type |
| 40 | |
Alexander Afanasyev | 05d4094 | 2013-08-09 12:43:26 -0700 | [diff] [blame] | 41 | # all other parameters are silently ignored |
| 42 | |
Alexander Afanasyev | fce5bbd | 2013-08-07 18:50:00 -0700 | [diff] [blame] | 43 | 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 Afanasyev | 40bc46d | 2013-08-08 01:27:12 -0700 | [diff] [blame] | 50 | if self.timestamp is not None: |
Alexander Afanasyev | fce5bbd | 2013-08-07 18:50:00 -0700 | [diff] [blame] | 51 | 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 | |