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): |
| 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 Afanasyev | 40bc46d | 2013-08-08 01:27:12 -0700 | [diff] [blame] | 47 | if self.timestamp is not None: |
Alexander Afanasyev | fce5bbd | 2013-08-07 18:50:00 -0700 | [diff] [blame] | 48 | 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 | |