当前位置: 首页>>代码示例>>Python>>正文


Python Data.wireDecode方法代码示例

本文整理汇总了Python中pyndn.Data.wireDecode方法的典型用法代码示例。如果您正苦于以下问题:Python Data.wireDecode方法的具体用法?Python Data.wireDecode怎么用?Python Data.wireDecode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyndn.Data的用法示例。


在下文中一共展示了Data.wireDecode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: benchmarkDecodeDataSeconds

# 需要导入模块: from pyndn import Data [as 别名]
# 或者: from pyndn.Data import wireDecode [as 别名]
def benchmarkDecodeDataSeconds(nIterations, useCrypto, keyType, encoding):
    """
    Loop to decode a data packet nIterations times.

    :param int nIterations: The number of iterations.
    :param bool useCrypto: If true, verify the signature.  If false, don't
      verify.
    :param KeyType keyType: KeyType.RSA or EC, used if useCrypto is True.
    :param Blob encoding: The wire encoding to decode.
    :return: The number of seconds for all iterations.
    :rtype: float
    """
    # Initialize the KeyChain in case useCrypto is true.
    keyChain = KeyChain("pib-memory:", "tpm-memory:")
    # This puts the public key in the pibImpl used by the SelfVerifyPolicyManager.
    keyChain.importSafeBag(SafeBag
      (Name("/testname/KEY/123"),
       Blob(DEFAULT_EC_PRIVATE_KEY_DER if keyType == KeyType.EC
            else DEFAULT_RSA_PRIVATE_KEY_DER, False),
       Blob(DEFAULT_EC_PUBLIC_KEY_DER if keyType == KeyType.EC
            else DEFAULT_RSA_PUBLIC_KEY_DER, False)))
    validator = Validator(ValidationPolicyFromPib(keyChain.getPib()))

    start = getNowSeconds()
    for i in range(nIterations):
        data = Data()
        data.wireDecode(encoding)

        if useCrypto:
            validator.validate(data,onVerifySuccess, onVerifyFailed)

    finish = getNowSeconds()

    return finish - start
开发者ID:named-data,项目名称:PyNDN2,代码行数:36,代码来源:test_encode_decode_benchmark.py

示例2: benchmarkDecodeDataSeconds

# 需要导入模块: from pyndn import Data [as 别名]
# 或者: from pyndn.Data import wireDecode [as 别名]
def benchmarkDecodeDataSeconds(nIterations, useCrypto, encoding):
    """
    Loop to decode a data packet nIterations times.

    :param int nIterations: The number of iterations.
    :param bool useCrypto: If true, verify the signature.  If false, don't
      verify.
    :param Blob encoding: The wire encoding to decode.
    """
    # Initialize the private key storage in case useCrypto is true.
    identityStorage = MemoryIdentityStorage()
    privateKeyStorage = MemoryPrivateKeyStorage()
    keyChain = KeyChain(IdentityManager(identityStorage, privateKeyStorage),
                        SelfVerifyPolicyManager(identityStorage))
    keyName = Name("/testname/DSK-123")
    certificateName = keyName.getSubName(0, keyName.size() - 1).append(
      "KEY").append(keyName[-1]).append("ID-CERT").append("0")
    identityStorage.addKey(keyName, KeyType.RSA, Blob(DEFAULT_RSA_PUBLIC_KEY_DER))

    start = getNowSeconds()
    for i in range(nIterations):
        data = Data()
        data.wireDecode(encoding)

        if useCrypto:
            keyChain.verifyData(data, onVerified, onVerifyFailed)

    finish = getNowSeconds()

    return finish - start
开发者ID:WeiqiJust,项目名称:NDN-total,代码行数:32,代码来源:test_encode_decode_benchmark.py

示例3: main

# 需要导入模块: from pyndn import Data [as 别名]
# 或者: from pyndn.Data import wireDecode [as 别名]
def main():
    data = Data()
    data.wireDecode(TlvData)

    # Use a hard-wired secret for testing. In a real application the signer
    # ensures that the verifier knows the shared key and its keyName.
    key = Blob(bytearray([
       0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
      16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
    ]))

    if KeyChain.verifyDataWithHmacWithSha256(data, key):
      dump("Hard-coded data signature verification: VERIFIED")
    else:
      dump("Hard-coded data signature verification: FAILED")

    freshData = Data(Name("/ndn/abc"))
    signature = HmacWithSha256Signature()
    signature.getKeyLocator().setType(KeyLocatorType.KEYNAME)
    signature.getKeyLocator().setKeyName(Name("key1"))
    freshData.setSignature(signature)
    freshData.setContent("SUCCESS!")
    dump("Signing fresh data packet", freshData.getName().toUri())
    KeyChain.signWithHmacWithSha256(freshData, key)

    if KeyChain.verifyDataWithHmacWithSha256(freshData, key):
      dump("Freshly-signed data signature verification: VERIFIED")
    else:
      dump("Freshly-signed data signature verification: FAILED")
开发者ID:MAHIS,项目名称:PyNDN2,代码行数:31,代码来源:test_sign_verify_data_hmac.py

示例4: __init__

# 需要导入模块: from pyndn import Data [as 别名]
# 或者: from pyndn.Data import wireDecode [as 别名]
    def __init__(self, identityName):
        super(DecryptorFixture, self).__init__()

        # Include the code here from the NAC unit-tests class
        # DecryptorStaticDataEnvironment instead of making it a base class.
        self._storage = InMemoryStorageRetaining()
        for array in EncryptStaticData.managerPackets:
            data = Data()
            data.wireDecode(array)
            self._storage.insert(data)

        for array in EncryptStaticData.encryptorPackets:
            data = Data()
            data.wireDecode(array)
            self._storage.insert(data)

        # Import the "/first/user" identity.
        self._keyChain.importSafeBag(
          SafeBag(EncryptStaticData.userIdentity),
          Blob("password").buf())

        self.addIdentity(Name("/not/authorized"))

        self._face = InMemoryStorageFace(self._storage)
        self._validator = ValidatorNull()
        self._decryptor = DecryptorV2(
          self._keyChain.getPib().getIdentity(identityName).getDefaultKey(),
          self._validator, self._keyChain, self._face)
开发者ID:named-data,项目名称:PyNDN2,代码行数:30,代码来源:test_decryptor_v2.py

示例5: test_refresh_10s

# 需要导入模块: from pyndn import Data [as 别名]
# 或者: from pyndn.Data import wireDecode [as 别名]
    def test_refresh_10s(self):
        with open('policy_config/testData', 'r') as dataFile:
            encodedData = dataFile.read()
            data = Data()
            dataBlob = Blob(b64decode(encodedData))
            data.wireDecode(dataBlob)

        # This test is needed, since the KeyChain will express interests in
        # unknown certificates.
        vr = doVerify(self.policyManager, data)

        self.assertTrue(vr.hasFurtherSteps,
          "ConfigPolicyManager did not create ValidationRequest for unknown certificate")
        self.assertEqual(vr.successCount, 0,
          "ConfigPolicyManager called success callback with pending ValidationRequest")
        self.assertEqual(vr.failureCount, 0,
          "ConfigPolicyManager called failure callback with pending ValidationRequest")

        # Now save the cert data to our anchor directory, and wait.
        # We have to sign it with the current identity or the policy manager
        # will create an interest for the signing certificate.

        cert = CertificateV2()
        certData = b64decode(CERT_DUMP)
        cert.wireDecode(Blob(certData, False))
        signingInfo = SigningInfo()
        signingInfo.setSigningIdentity(self.identityName)
        # Make sure the validity period is current for two years.
        now = Common.getNowMilliseconds()
        signingInfo.setValidityPeriod(ValidityPeriod
          (now, now + 2 * 365 * 24 * 3600 * 1000.0))

        self.keyChain.sign(cert, signingInfo)
        encodedCert = b64encode(cert.wireEncode().toBytes())
        with open(self.testCertFile, 'w') as certFile:
            certFile.write(Blob(encodedCert, False).toRawStr())

        # Still too early for refresh to pick it up.
        vr = doVerify(self.policyManager, data)

        self.assertTrue(vr.hasFurtherSteps,
          "ConfigPolicyManager refresh occured sooner than specified")
        self.assertEqual(vr.successCount, 0,
          "ConfigPolicyManager called success callback with pending ValidationRequest")
        self.assertEqual(vr.failureCount, 0,
          "ConfigPolicyManager called failure callback with pending ValidationRequest")
        time.sleep(6)

        # Now we should find it.
        vr  = doVerify(self.policyManager, data)

        self.assertFalse(vr.hasFurtherSteps,
          "ConfigPolicyManager did not refresh certificate store")
        self.assertEqual(vr.successCount, 1,
          "Verification success called {} times instead of 1".format(
            vr.successCount))
        self.assertEqual(vr.failureCount, 0,
          "ConfigPolicyManager did not verify valid signed data")
开发者ID:named-data,项目名称:PyNDN2,代码行数:60,代码来源:test_policy_manager_v2.py

示例6: test_encode_decode

# 需要导入模块: from pyndn import Data [as 别名]
# 或者: from pyndn.Data import wireDecode [as 别名]
    def test_encode_decode(self):
        data = Data()
        data.wireDecode(codedData)
        data.setContent(data.getContent())
        encoding = data.wireEncode()

        reDecodedData = Data()
        reDecodedData.wireDecode(encoding)
        self.assertEqual(dumpData(reDecodedData), initialDump, 'Re-decoded data does not match original dump')
开发者ID:bboalimoe,项目名称:PyNDN2,代码行数:11,代码来源:test_data_methods.py

示例7: test_refresh_10s

# 需要导入模块: from pyndn import Data [as 别名]
# 或者: from pyndn.Data import wireDecode [as 别名]
    def test_refresh_10s(self):
        with open('policy_config/testData', 'r') as dataFile:
            encodedData = dataFile.read()
            data = Data()
            dataBlob = Blob(b64decode(encodedData))
            data.wireDecode(dataBlob)

        # needed, since the KeyChain will express interests in unknown
        # certificates
        vr = doVerify(self.policyManager, data)

        self.assertTrue(vr.hasFurtherSteps,
                "ConfigPolicyManager did not create ValidationRequest for unknown certificate")
        self.assertEqual(vr.successCount, 0,
                "ConfigPolicyManager called success callback with pending ValidationRequest")
        self.assertEqual(vr.failureCount, 0,
                "ConfigPolicyManager called failure callback with pending ValidationRequest")

        # now save the cert data to our anchor directory, and wait
        # we have to sign it with the current identity or the
        # policy manager will create an interest for the signing certificate

        with open(self.testCertFile, 'w') as certFile:
            cert = IdentityCertificate()
            certData = b64decode(CERT_DUMP)
            cert.wireDecode(Blob(certData, False))
            self.keyChain.signByIdentity(cert, self.identityName)
            encodedCert = b64encode(cert.wireEncode().toBuffer())
            certFile.write(Blob(encodedCert, False).toRawStr())

        # still too early for refresh to pick it up
        vr = doVerify(self.policyManager, data)

        self.assertTrue(vr.hasFurtherSteps,
                "ConfigPolicyManager refresh occured sooner than specified")
        self.assertEqual(vr.successCount, 0,
                "ConfigPolicyManager called success callback with pending ValidationRequest")
        self.assertEqual(vr.failureCount, 0,
                "ConfigPolicyManager called failure callback with pending ValidationRequest")
        time.sleep(6)

        # now we should find it
        vr  = doVerify(self.policyManager, data)

        self.assertFalse(vr.hasFurtherSteps,
                "ConfigPolicyManager did not refresh certificate store")
        self.assertEqual(vr.successCount, 1,
                "Verification success called {} times instead of 1".format(
                    vr.successCount))
        self.assertEqual(vr.failureCount, 0,
                "ConfigPolicyManager did not verify valid signed data")
开发者ID:mjycom,项目名称:PyNDN2,代码行数:53,代码来源:test_policy_manager.py

示例8: test_get_group_key_without_regeneration

# 需要导入模块: from pyndn import Data [as 别名]
# 或者: from pyndn.Data import wireDecode [as 别名]
    def test_get_group_key_without_regeneration(self):
        # Create the group manager.
        manager = GroupManager(
          Name("Alice"), Name("data_type"),
          Sqlite3GroupManagerDb(self.groupKeyDatabaseFilePath), 1024, 1,
          self.keyChain)
        self.setManager(manager)

        # Get the data list from the group manager.
        timePoint1 = Schedule.fromIsoString("20150825T093000")
        result = manager.getGroupKey(timePoint1)

        self.assertEqual(4, len(result))

        # The first data packet contains the group's encryption key (public key).
        data1 = result[0]
        self.assertEqual(
          "/Alice/READ/data_type/E-KEY/20150825T090000/20150825T100000",
          data1.getName().toUri())
        groupEKey1 = EncryptKey(data1.getContent())

        # Get the second data packet and decrypt.
        data = result[1]
        self.assertEqual(
          "/Alice/READ/data_type/D-KEY/20150825T090000/20150825T100000/FOR/ndn/memberA/ksk-123",
          data.getName().toUri())

        # Add new members to the database.
        dataBlob = self.certificate.wireEncode()
        memberD = Data()
        memberD.wireDecode(dataBlob)
        memberD.setName(Name("/ndn/memberD/KEY/ksk-123/ID-CERT/123"))
        manager.addMember("schedule1", memberD)

        result2 = manager.getGroupKey(timePoint1, False)
        self.assertEqual(5, len(result2))

        # Check that the new EKey is the same as the previous one.
        data2 = result2[0]
        self.assertEqual(
          "/Alice/READ/data_type/E-KEY/20150825T090000/20150825T100000",
           data2.getName().toUri())
        groupEKey2 = EncryptKey(data2.getContent())
        self.assertTrue(groupEKey1.getKeyBits().equals(groupEKey2.getKeyBits()));

        # Check the second data packet.
        data2 = result2[1]
        self.assertEqual(
          "/Alice/READ/data_type/D-KEY/20150825T090000/20150825T100000/FOR/ndn/memberA/ksk-123",
          data2.getName().toUri())
开发者ID:named-data,项目名称:PyNDN2,代码行数:52,代码来源:test_group_manager.py

示例9: test_congestion_mark

# 需要导入模块: from pyndn import Data [as 别名]
# 或者: from pyndn.Data import wireDecode [as 别名]
    def test_congestion_mark(self):
        # Imitate onReceivedElement.
        lpPacket = LpPacket()
        # Set copy False so that the fragment is a slice which will be
        # copied below. The header fields are all integers and don't need to
        # be copied.
        TlvWireFormat.get().decodeLpPacket(lpPacket, CONGESTION_MARK_PACKET.buf(), False)
        element = lpPacket.getFragmentWireEncoding().buf()

        data = Data()
        data.wireDecode(element, TlvWireFormat.get())
        data.setLpPacket(lpPacket)

        self.assertEqual(1, data.getCongestionMark())
开发者ID:named-data,项目名称:PyNDN2,代码行数:16,代码来源:test_data_methods.py

示例10: test_generic_signature

# 需要导入模块: from pyndn import Data [as 别名]
# 或者: from pyndn.Data import wireDecode [as 别名]
    def test_generic_signature(self):
        # Test correct encoding.
        signature = GenericSignature()
        signature.setSignatureInfoEncoding(
          Blob(experimentalSignatureInfo, False), None)
        signatureValue = Blob([1, 2, 3, 4], False)
        signature.setSignature(signatureValue)

        self.freshData.setSignature(signature)
        encoding = self.freshData.wireEncode()

        decodedData = Data()
        decodedData.wireDecode(encoding)

        decodedSignature = decodedData.getSignature()
        self.assertEqual(decodedSignature.getTypeCode(), experimentalSignatureType)
        self.assertTrue(Blob(experimentalSignatureInfo, False).equals
                        (decodedSignature.getSignatureInfoEncoding()))
        self.assertTrue(signatureValue.equals(decodedSignature.getSignature()))

        # Test bad encoding.
        signature = GenericSignature()
        signature.setSignatureInfoEncoding(
          Blob(experimentalSignatureInfoNoSignatureType, False), None)
        signature.setSignature(signatureValue)
        self.freshData.setSignature(signature)
        gotError = True
        try:
            self.freshData.wireEncode()
            gotError = False
        except:
            pass
        if not gotError:
          self.fail("Expected encoding error for experimentalSignatureInfoNoSignatureType")

        signature = GenericSignature()
        signature.setSignatureInfoEncoding(
          Blob(experimentalSignatureInfoBadTlv, False), None)
        signature.setSignature(signatureValue)
        self.freshData.setSignature(signature)
        gotError = True
        try:
            self.freshData.wireEncode()
            gotError = False
        except:
            pass
        if not gotError:
          self.fail("Expected encoding error for experimentalSignatureInfoBadTlv")
开发者ID:MAHIS,项目名称:PyNDN2,代码行数:50,代码来源:test_data_methods.py

示例11: main

# 需要导入模块: from pyndn import Data [as 别名]
# 或者: from pyndn.Data import wireDecode [as 别名]
def main():
    data = Data()
    data.wireDecode(TlvData)
    dump("Decoded Data:")
    dumpData(data)

    # Set the content again to clear the cached encoding so we encode again.
    data.setContent(data.getContent())
    encoding = data.wireEncode()

    reDecodedData = Data()
    reDecodedData.wireDecode(encoding)
    dump("")
    dump("Re-decoded Data:")
    dumpData(reDecodedData)

    identityStorage = MemoryIdentityStorage()
    privateKeyStorage = MemoryPrivateKeyStorage()
    keyChain = KeyChain(IdentityManager(identityStorage, privateKeyStorage),
                        SelfVerifyPolicyManager(identityStorage))

    # Initialize the storage.
    keyName = Name("/testname/DSK-123")
    certificateName = keyName.getSubName(0, keyName.size() - 1).append(
      "KEY").append(keyName[-1]).append("ID-CERT").append("0")
    identityStorage.addKey(keyName, KeyType.RSA, Blob(DEFAULT_RSA_PUBLIC_KEY_DER))
    privateKeyStorage.setKeyPairForKeyName(
      keyName, KeyType.RSA, DEFAULT_RSA_PUBLIC_KEY_DER, DEFAULT_RSA_PRIVATE_KEY_DER)

    keyChain.verifyData(reDecodedData, makeOnVerified("Re-decoded Data"),
                        makeOnVerifyFailed("Re-decoded Data"))

    freshData = Data(Name("/ndn/abc"))
    freshData.setContent("SUCCESS!")
    freshData.getMetaInfo().setFreshnessPeriod(5000)
    freshData.getMetaInfo().setFinalBlockId(Name("/%00%09")[0])
    keyChain.sign(freshData, certificateName)
    dump("")
    dump("Freshly-signed Data:")
    dumpData(freshData)

    keyChain.verifyData(freshData, makeOnVerified("Freshly-signed Data"),
                        makeOnVerifyFailed("Freshly-signed Data"))
开发者ID:mjycom,项目名称:PyNDN2,代码行数:45,代码来源:test_encode_decode_data.py

示例12: main

# 需要导入模块: from pyndn import Data [as 别名]
# 或者: from pyndn.Data import wireDecode [as 别名]
def main():
    data = Data()
    data.wireDecode(TlvData)
    dump("Decoded Data:")
    dumpData(data)

    # Set the content again to clear the cached encoding so we encode again.
    data.setContent(data.getContent())
    encoding = data.wireEncode()

    reDecodedData = Data()
    reDecodedData.wireDecode(encoding)
    dump("")
    dump("Re-decoded Data:")
    dumpData(reDecodedData)

    # Set up the KeyChain.
    keyChain = KeyChain("pib-memory:", "tpm-memory:")
    keyChain.importSafeBag(SafeBag
      (Name("/testname/KEY/123"),
       Blob(DEFAULT_RSA_PRIVATE_KEY_DER, False),
       Blob(DEFAULT_RSA_PUBLIC_KEY_DER, False)))
    validator = Validator(ValidationPolicyFromPib(keyChain.getPib()))

    validator.validate(reDecodedData, makeSuccessCallback("Re-decoded Data"),
      makeFailureCallback("Re-decoded Data"))

    freshData = Data(Name("/ndn/abc"))
    freshData.setContent("SUCCESS!")
    freshData.getMetaInfo().setFreshnessPeriod(5000)
    freshData.getMetaInfo().setFinalBlockId(Name("/%00%09")[0])
    keyChain.sign(freshData)
    dump("")
    dump("Freshly-signed Data:")
    dumpData(freshData)

    validator.validate(freshData, makeSuccessCallback("Freshly-signed Data"),
      makeFailureCallback("Freshly-signed Data"))
开发者ID:named-data,项目名称:PyNDN2,代码行数:40,代码来源:test_encode_decode_data.py

示例13: extract_co_from_db

# 需要导入模块: from pyndn import Data [as 别名]
# 或者: from pyndn.Data import wireDecode [as 别名]
    def extract_co_from_db(self, leaf_node, wired=True):
        try:
            # by design, there is AT MOST one C2S relation for each node
            query = 'START s=node(%s)\n' % leaf_node._id + \
                    'MATCH (s)-[r:%s]->(c)\n' % RELATION_C2S + \
                    'RETURN c'
            records = neo4j.CypherQuery(self.db_handler, query).execute()
            nodes = [record.values[0] for record in records.data]
            segment_node = nodes[0]

            properties = segment_node.get_properties()
            wrapped = eval(properties[PROPERTY_WRAPPED])
            _data = properties[PROPERTY_DATA]
            data = base64.b64decode(_data)
            # decode wired co to ContentObject instance
#            if not wired:
            co = Data()
            co.wireDecode(Blob.fromRawStr(data))
            return co
#            else:
#                return data
        except StopIteration as ex:
            return None
开发者ID:remap,项目名称:BMS-REPO,代码行数:25,代码来源:repo.py

示例14: test_full_name

# 需要导入模块: from pyndn import Data [as 别名]
# 或者: from pyndn.Data import wireDecode [as 别名]
    def test_full_name(self):
        data = Data()
        data.wireDecode(codedData)

        # Check the full name format.
        self.assertEqual(data.getFullName().size(), data.getName().size() + 1)
        self.assertEqual(data.getName(), data.getFullName().getPrefix(-1))
        self.assertEqual(data.getFullName().get(-1).getValue().size(), 32)

        # Check the independent digest calculation.
        sha256 = hashes.Hash(hashes.SHA256(), backend=default_backend())
        sha256.update(Blob(codedData).toBytes())
        newDigest = Blob(bytearray(sha256.finalize()), False)
        self.assertTrue(newDigest.equals(data.getFullName().get(-1).getValue()))

        # Check the expected URI.
        self.assertEqual(
          data.getFullName().toUri(), "/ndn/abc/sha256digest=" +
            "96556d685dcb1af04be4ae57f0e7223457d4055ea9b3d07c0d337bef4a8b3ee9")

        # Changing the Data packet should change the full name.
        saveFullName = Name(data.getFullName())
        data.setContent(Blob())
        self.assertNotEqual(data.getFullName().get(-1), saveFullName.get(-1))
开发者ID:named-data,项目名称:PyNDN2,代码行数:26,代码来源:test_data_methods.py

示例15: setManager

# 需要导入模块: from pyndn import Data [as 别名]
# 或者: from pyndn.Data import wireDecode [as 别名]
    def setManager(self, manager):
        # Set up the first schedule.
        schedule1 = Schedule()
        interval11 = RepetitiveInterval(
          Schedule.fromIsoString("20150825T000000"),
          Schedule.fromIsoString("20150827T000000"), 5, 10, 2,
          RepetitiveInterval.RepeatUnit.DAY)
        interval12 = RepetitiveInterval(
          Schedule.fromIsoString("20150825T000000"),
          Schedule.fromIsoString("20150827T000000"), 6, 8, 1,
          RepetitiveInterval.RepeatUnit.DAY)
        interval13 = RepetitiveInterval(
          Schedule.fromIsoString("20150827T000000"),
          Schedule.fromIsoString("20150827T000000"), 7, 8)
        schedule1.addWhiteInterval(interval11)
        schedule1.addWhiteInterval(interval12)
        schedule1.addBlackInterval(interval13)

        # Set up the second schedule.
        schedule2 = Schedule()
        interval21 = RepetitiveInterval(
          Schedule.fromIsoString("20150825T000000"),
          Schedule.fromIsoString("20150827T000000"), 9, 12, 1,
          RepetitiveInterval.RepeatUnit.DAY)
        interval22 = RepetitiveInterval(
          Schedule.fromIsoString("20150827T000000"),
          Schedule.fromIsoString("20150827T000000"), 6, 8)
        interval23 = RepetitiveInterval(
          Schedule.fromIsoString("20150827T000000"),
          Schedule.fromIsoString("20150827T000000"), 2, 4)
        schedule2.addWhiteInterval(interval21)
        schedule2.addWhiteInterval(interval22)
        schedule2.addBlackInterval(interval23)

        # Add them to the group manager database.
        manager.addSchedule("schedule1", schedule1)
        manager.addSchedule("schedule2", schedule2)

        # Make some adaptions to certificate.
        dataBlob = self.certificate.wireEncode()

        memberA = Data()
        memberA.wireDecode(dataBlob, TlvWireFormat.get())
        memberA.setName(Name("/ndn/memberA/KEY/ksk-123/ID-CERT/123"))
        memberB = Data()
        memberB.wireDecode(dataBlob, TlvWireFormat.get())
        memberB.setName(Name("/ndn/memberB/KEY/ksk-123/ID-CERT/123"))
        memberC = Data()
        memberC.wireDecode(dataBlob, TlvWireFormat.get())
        memberC.setName(Name("/ndn/memberC/KEY/ksk-123/ID-CERT/123"))

        # Add the members to the database.
        manager.addMember("schedule1", memberA)
        manager.addMember("schedule1", memberB)
        manager.addMember("schedule2", memberC)
开发者ID:named-data,项目名称:PyNDN2,代码行数:57,代码来源:test_group_manager.py


注:本文中的pyndn.Data.wireDecode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。