def publish(key, name, last_segment, content): print("Generating: %s" % name) # Name co_name = Name.Name(name) # SignedInfo si = ContentObject.SignedInfo() si.type = ContentObject.ContentType.CCN_CONTENT_DATA si.finalBlockID = last_segment si.publisherPublicKeyDigest = key.publicKeyID si.keyLocator = Key.KeyLocator(key) # ContentObject co = ContentObject.ContentObject() co.content = content co.name = co_name co.signedInfo = si co.sign(key) return co
def publish_content(self, name, content, freshness=5): '''Publish the data as a Content Object Args: name (str): the name string content (bytes): the data bytes Kwargs: freshness (int): the freshness in seconds for the Content Object ''' co = ContentObject() co.name = self.get_pyccn_name(name) co.content = content si = self.get_signed_info(freshness) co.signedInfo = si co.sign(self.ccnx_key) self.ccnx_handle.put(co)
def makeDefaultContent(self, name, content): co = ContentObject() # since they want us to use versions and segments append those to our name co.name = Name(name) # making copy, so any changes to co.name won't change self.name co.name.appendVersion() # timestamp which is our version co.name.append(b'\x00') # first segment co.content = content #"LIGHT OK" si = pyccn.SignedInfo() si.publisherPublicKeyDigest = self.key.publicKeyID si.type = 0x28463F # key type #si.type = 0x0C04C0 # content type si.finalBlockID = b'\x00' # no more segments available si.keyLocator = self.keyLocator co.signedInfo = si co.sign(self.key) return co
def publish(self, name, content): # Name #print name # SignedInfo si = pyccn.SignedInfo() #si.type = pyccn.CCN_CONTENT_DATA si.type = 0x0C04C0 # content type si.finalBlockID = b'\x00' si.publisherPublicKeyDigest = self.key.publicKeyID si.keyLocator = self.keylocator si.freshnessSeconds = FRESHNESS_SECONDS # ContentObject co = ContentObject() co.content = content co.name = name co.signedInfo = si co.sign(self.key) return co
def publish_content(self, name, content, freshness = 5): '''Publish the data as a Content Object Args: name (str): the name string content (bytes): the data bytes Kwargs: freshness (int): the freshness in seconds for the Content Object ''' co = ContentObject() co.name = self.get_pyccn_name(name) co.content = content si = self.get_signed_info(freshness) co.signedInfo = si co.sign(self.ccnx_key) self.ccnx_handle.put(co)
def upcall(self, kind, upcallInfo): global sender_handle, n, k, kl print("Sender closure:") print(upcallInfo) co = ContentObject() co.name = Name(n) co.content = "Frou" si = SignedInfo() si.publisherPublicKeyDigest = k.publicKeyID si.type = pyccn.CONTENT_DATA si.freshnessSeconds = 5 si.keyLocator = kl co.signedInfo = si co.sign(k) r = sender_handle.put(co) print("put(co) = ", r) #sender_handle.setRunTimeout(0) return pyccn.RESULT_INTEREST_CONSUMED