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


C# Interest.getExclude方法代码示例

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


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

示例1: dumpInterest

 static void dumpInterest(Interest interest)
 {
     Console.Out.WriteLine("name: " + interest.getName().toUri());
       Console.Out.WriteLine("minSuffixComponents: " +
     (interest.getMinSuffixComponents() >= 0 ?
       "" + interest.getMinSuffixComponents() : "<none>"));
       Console.Out.WriteLine("maxSuffixComponents: " +
     (interest.getMaxSuffixComponents() >= 0 ?
       "" + interest.getMaxSuffixComponents() : "<none>"));
       Console.Out.Write("keyLocator: ");
       if (interest.getKeyLocator().getType() == KeyLocatorType.NONE)
     Console.Out.WriteLine("<none>");
       else if (interest.getKeyLocator().getType() ==KeyLocatorType.KEY_LOCATOR_DIGEST)
     Console.Out.WriteLine("KeyLocatorDigest: " + interest.getKeyLocator().getKeyData().toHex());
       else if (interest.getKeyLocator().getType() == KeyLocatorType.KEYNAME)
     Console.Out.WriteLine("KeyName: " + interest.getKeyLocator().getKeyName().toUri());
       else
     Console.Out.WriteLine("<unrecognized ndn_KeyLocatorType>");
       Console.Out.WriteLine
       ("exclude: " + (interest.getExclude().size() > 0 ?
     interest.getExclude().toUri() : "<none>"));
       Console.Out.WriteLine("lifetimeMilliseconds: " +
     (interest.getInterestLifetimeMilliseconds() >= 0 ?
       "" + interest.getInterestLifetimeMilliseconds() : "<none>"));
       Console.Out.WriteLine("childSelector: " +
     (interest.getChildSelector() >= 0 ?
       "" + interest.getChildSelector() : "<none>"));
       Console.Out.WriteLine("mustBeFresh: " + interest.getMustBeFresh());
       Console.Out.WriteLine("nonce: " +
     (interest.getNonce().size() > 0 ?
       "" + interest.getNonce().toHex() : "<none>"));
 }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:32,代码来源:test-encode-decode-interest.cs

示例2: Main

        static void Main(string[] args)
        {
            var interest = new Interest();
              interest.wireDecode(new Blob(TlvInterest));
              Console.Out.WriteLine("Interest:");
              dumpInterest(interest);

              // Set the name again to clear the cached encoding so we encode again.
              interest.setName(interest.getName());
              var encoding = interest.wireEncode();
              Console.Out.WriteLine("");
              Console.Out.WriteLine("Re-encoded interest " + encoding.toHex());

              var reDecodedInterest = new Interest();
              reDecodedInterest.wireDecode(encoding);
              Console.Out.WriteLine("");
              Console.Out.WriteLine("Re-decoded Interest:");
              dumpInterest(reDecodedInterest);

              var freshInterest = new Interest(new Name("/ndn/abc"));
              freshInterest.setMinSuffixComponents(4);
              freshInterest.setMaxSuffixComponents(6);
              freshInterest.setInterestLifetimeMilliseconds(30000);
              freshInterest.setChildSelector(1);
              freshInterest.setMustBeFresh(true);
              freshInterest.getKeyLocator().setType(KeyLocatorType.KEY_LOCATOR_DIGEST);
              freshInterest.getKeyLocator().setKeyData
            (new Blob(new byte[] {
              0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
              0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }));
              freshInterest.getExclude().appendComponent(new Name("abc").get(0)).appendAny();

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

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

              // Make a Face just so that we can sign the interest.
              var face = new Face("localhost");
              face.setCommandSigningInfo(keyChain, certificateName);
              face.makeCommandInterest(freshInterest);

              Interest reDecodedFreshInterest = new Interest();
              reDecodedFreshInterest.wireDecode(freshInterest.wireEncode());
              Console.Out.WriteLine("");
              Console.Out.WriteLine("Re-decoded fresh Interest:");
              dumpInterest(reDecodedFreshInterest);

              VerifyCallbacks callbacks = new VerifyCallbacks("Freshly-signed Interest");
              keyChain.verifyInterest(reDecodedFreshInterest, callbacks, callbacks);
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:61,代码来源:test-encode-decode-interest.cs

示例3: decodeSelectors

        private static void decodeSelectors(Interest interest, TlvDecoder decoder,
				bool copy)
        {
            int endOffset = decoder.readNestedTlvsStart(net.named_data.jndn.encoding.tlv.Tlv.Selectors);

            interest.setMinSuffixComponents((int) decoder
                    .readOptionalNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.MinSuffixComponents,
                            endOffset));
            interest.setMaxSuffixComponents((int) decoder
                    .readOptionalNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.MaxSuffixComponents,
                            endOffset));

            if (decoder.peekType(net.named_data.jndn.encoding.tlv.Tlv.PublisherPublicKeyLocator, endOffset))
                decodeKeyLocator(net.named_data.jndn.encoding.tlv.Tlv.PublisherPublicKeyLocator,
                        interest.getKeyLocator(), decoder, copy);
            else
                interest.getKeyLocator().clear();

            if (decoder.peekType(net.named_data.jndn.encoding.tlv.Tlv.Exclude, endOffset))
                decodeExclude(interest.getExclude(), decoder, copy);
            else
                interest.getExclude().clear();

            interest.setChildSelector((int) decoder
                    .readOptionalNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.ChildSelector, endOffset));
            interest.setMustBeFresh(decoder.readBooleanTlv(net.named_data.jndn.encoding.tlv.Tlv.MustBeFresh,
                    endOffset));

            decoder.finishNestedTlvs(endOffset);
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:30,代码来源:Tlv0_2WireFormat.cs

示例4: Interest

        /// <summary>
        /// Create a new interest as a deep copy of the given interest.
        /// </summary>
        ///
        /// <param name="interest">The interest to copy.</param>
        public Interest(Interest interest)
        {
            this.name_ = new ChangeCounter(new Name());
            this.minSuffixComponents_ = -1;
            this.maxSuffixComponents_ = -1;
            this.keyLocator_ = new ChangeCounter(
                    new KeyLocator());
            this.exclude_ = new ChangeCounter(new Exclude());
            this.childSelector_ = -1;
            this.mustBeFresh_ = true;
            this.interestLifetimeMilliseconds_ = -1;
            this.nonce_ = new Blob();
            this.getNonceChangeCount_ = 0;
            this.lpPacket_ = null;
            this.linkWireEncoding_ = new Blob();
            this.linkWireEncodingFormat_ = null;
            this.link_ = new ChangeCounter(null);
            this.selectedDelegationIndex_ = -1;
            this.defaultWireEncoding_ = new SignedBlob();
            this.getDefaultWireEncodingChangeCount_ = 0;
            this.changeCount_ = 0;
            name_.set(new Name(interest.getName()));
            minSuffixComponents_ = interest.minSuffixComponents_;
            maxSuffixComponents_ = interest.maxSuffixComponents_;
            keyLocator_.set(new KeyLocator(interest.getKeyLocator()));
            exclude_.set(new Exclude(interest.getExclude()));
            childSelector_ = interest.childSelector_;
            mustBeFresh_ = interest.mustBeFresh_;

            interestLifetimeMilliseconds_ = interest.interestLifetimeMilliseconds_;
            nonce_ = interest.getNonce();

            linkWireEncoding_ = interest.linkWireEncoding_;
            linkWireEncodingFormat_ = interest.linkWireEncodingFormat_;
            if (interest.link_.get() != null)
                link_.set(new Link((Link) interest.link_.get()));
            selectedDelegationIndex_ = interest.selectedDelegationIndex_;

            setDefaultWireEncoding(interest.getDefaultWireEncoding(),
                    interest.defaultWireEncodingFormat_);
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:46,代码来源:Interest.cs

示例5: handleCoveringKey

        /// <summary>
        /// This is called from an expressInterest OnData to check that the encryption
        /// key contained in data fits the timeSlot. This sends a refined interest if
        /// required.
        /// </summary>
        ///
        /// <param name="interest">The interest given to expressInterest.</param>
        /// <param name="data">The fetched Data packet.</param>
        /// <param name="timeSlot_0">The time slot as milliseconds since Jan 1, 1970 UTC.</param>
        /// <param name="onEncryptedKeys_1">encrypted content key Data packets. If onEncryptedKeys is null, this does not use it.</param>
        internal void handleCoveringKey(Interest interest, Data data,
				double timeSlot_0, Producer.OnEncryptedKeys  onEncryptedKeys_1, net.named_data.jndn.encrypt.EncryptError.OnError  onError_2)
        {
            double timeCount = Math.Round(timeSlot_0,MidpointRounding.AwayFromZero);
            Producer.KeyRequest  keyRequest = (Producer.KeyRequest ) ILOG.J2CsMapping.Collections.Collections.Get(keyRequests_,timeCount);

            Name interestName = interest.getName();
            Name keyName = data.getName();

            double begin = net.named_data.jndn.encrypt.Schedule.fromIsoString(keyName
                    .get(START_TIME_STAMP_INDEX).getValue().toString());
            double end = net.named_data.jndn.encrypt.Schedule.fromIsoString(keyName.get(END_TIME_STAMP_INDEX)
                    .getValue().toString());

            if (timeSlot_0 >= end) {
                // If the received E-KEY covers some earlier period, try to retrieve an
                // E-KEY covering a later one.
                Exclude timeRange = new Exclude(interest.getExclude());
                excludeBefore(timeRange, keyName.get(START_TIME_STAMP_INDEX));
                ILOG.J2CsMapping.Collections.Collections.Put(keyRequest.repeatAttempts,interestName,0);

                sendKeyInterest(new Interest(interestName).setExclude(timeRange)
                        .setChildSelector(1), timeSlot_0, onEncryptedKeys_1, onError_2);
            } else {
                // If the received E-KEY covers the content key, encrypt the content.
                Blob encryptionKey = data.getContent();
                // If everything is correct, save the E-KEY as the current key.
                if (encryptContentKey(encryptionKey, keyName, timeSlot_0,
                        onEncryptedKeys_1, onError_2)) {
                    Producer.KeyInfo  keyInfo = (Producer.KeyInfo ) ILOG.J2CsMapping.Collections.Collections.Get(eKeyInfo_,interestName);
                    keyInfo.beginTimeSlot = begin;
                    keyInfo.endTimeSlot = end;
                    keyInfo.keyBits = encryptionKey;
                }
            }
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:46,代码来源:Producer.cs

示例6: encodeSelectors

        /// <summary>
        /// Encode the interest selectors.  If no selectors are written, do not output
        /// a  Selectors TLV.
        /// </summary>
        ///
        private static void encodeSelectors(Interest interest, TlvEncoder encoder)
        {
            int saveLength = encoder.getLength();

            // Encode backwards.
            if (interest.getMustBeFresh())
                encoder.writeTypeAndLength(net.named_data.jndn.encoding.tlv.Tlv.MustBeFresh, 0);
            encoder.writeOptionalNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.ChildSelector,
                    interest.getChildSelector());
            if (interest.getExclude().size() > 0)
                encodeExclude(interest.getExclude(), encoder);

            if (interest.getKeyLocator().getType() != net.named_data.jndn.KeyLocatorType.NONE)
                encodeKeyLocator(net.named_data.jndn.encoding.tlv.Tlv.PublisherPublicKeyLocator,
                        interest.getKeyLocator(), encoder);

            encoder.writeOptionalNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.MaxSuffixComponents,
                    interest.getMaxSuffixComponents());
            encoder.writeOptionalNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.MinSuffixComponents,
                    interest.getMinSuffixComponents());

            // Only output the type and length if values were written.
            if (encoder.getLength() != saveLength)
                encoder.writeTypeAndLength(net.named_data.jndn.encoding.tlv.Tlv.Selectors, encoder.getLength()
                        - saveLength);
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:31,代码来源:Tlv0_2WireFormat.cs

示例7: dumpInterest

 private static ArrayList dumpInterest(Interest interest)
 {
     ArrayList result = new ArrayList();
     ILOG.J2CsMapping.Collections.Collections.Add(result,dump("name:", interest.getName().toUri()));
     ILOG.J2CsMapping.Collections.Collections.Add(result,dump(
                     "minSuffixComponents:",
                     (interest.getMinSuffixComponents() >= 0) ? (Object) (interest.getMinSuffixComponents()) : (Object) ("<none>")));
     ILOG.J2CsMapping.Collections.Collections.Add(result,dump(
                     "maxSuffixComponents:",
                     (interest.getMaxSuffixComponents() >= 0) ? (Object) (interest.getMaxSuffixComponents()) : (Object) ("<none>")));
     if (interest.getKeyLocator().getType() != net.named_data.jndn.KeyLocatorType.NONE) {
         if (interest.getKeyLocator().getType() == net.named_data.jndn.KeyLocatorType.KEY_LOCATOR_DIGEST)
             ILOG.J2CsMapping.Collections.Collections.Add(result,dump("keyLocator: KeyLocatorDigest:", interest
                                     .getKeyLocator().getKeyData().toHex()));
         else if (interest.getKeyLocator().getType() == net.named_data.jndn.KeyLocatorType.KEYNAME)
             ILOG.J2CsMapping.Collections.Collections.Add(result,dump("keyLocator: KeyName:", interest
                                     .getKeyLocator().getKeyName().toUri()));
         else
             ILOG.J2CsMapping.Collections.Collections.Add(result,dump("keyLocator: <unrecognized KeyLocatorType"));
     } else
         ILOG.J2CsMapping.Collections.Collections.Add(result,dump("keyLocator: <none>"));
     ILOG.J2CsMapping.Collections.Collections.Add(result,dump("exclude:", (interest.getExclude().size() > 0) ? interest
                     .getExclude().toUri() : "<none>"));
     ILOG.J2CsMapping.Collections.Collections.Add(result,dump("childSelector:",
                     (interest.getChildSelector() >= 0) ? (Object) (interest.getChildSelector())
                             : (Object) ("<none>")));
     ILOG.J2CsMapping.Collections.Collections.Add(result,dump("mustBeFresh:", (interest.getMustBeFresh()) ? "true"
                     : "false"));
     ILOG.J2CsMapping.Collections.Collections.Add(result,dump("nonce:", (interest.getNonce().size() == 0) ? "<none>"
                     : interest.getNonce().toHex()));
     ILOG.J2CsMapping.Collections.Collections.Add(result,dump("lifetimeMilliseconds:",
                     (interest.getInterestLifetimeMilliseconds() < 0) ? "<none>" : ""
                             + (long) interest.getInterestLifetimeMilliseconds()));
     return result;
 }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:35,代码来源:TestInterestMethods.cs

示例8: createFreshInterest

        private static Interest createFreshInterest()
        {
            Interest freshInterest = new Interest(new Name("/ndn/abc"))
                    .setMustBeFresh(false).setMinSuffixComponents(4)
                    .setMaxSuffixComponents(6)
                    .setInterestLifetimeMilliseconds(30000).setChildSelector(1)
                    .setMustBeFresh(true);
            freshInterest.getKeyLocator()
                    .setType(net.named_data.jndn.KeyLocatorType.KEY_LOCATOR_DIGEST);
            freshInterest.getKeyLocator().setKeyData(
                    new Blob(new int[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
                            0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
                            0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
                            0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }));
            freshInterest.getExclude().appendComponent(new Name("abc").get(0))
                    .appendAny();

            return freshInterest;
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:19,代码来源:TestInterestMethods.cs

示例9: testSetRemovesNonce

 public void testSetRemovesNonce()
 {
     // Ensure that changing a value on an interest clears the nonce.
     Assert.AssertFalse(referenceInterest.getNonce().isNull());
     Interest interest = new Interest(referenceInterest);
     // Change a child object.
     interest.getExclude().clear();
     Assert.AssertTrue("Interest should not have a nonce after changing fields",
             interest.getNonce().isNull());
 }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:10,代码来源:TestInterestMethods.cs

示例10: testRedecodeImplicitDigestExclude

        public void testRedecodeImplicitDigestExclude()
        {
            // Check that we encode and decode correctly with an implicit digest exclude.
            Interest interest = new Interest(new Name("/A"));
            interest.getExclude()
                    .appendComponent(
                            new Name(
                                    "/sha256digest="
                                            + "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")
                                    .get(0));
            ArrayList dump = dumpInterest(interest);

            Blob encoding = interest.wireEncode();
            Interest reDecodedInterest = new Interest();
            try {
                reDecodedInterest.wireDecode(encoding);
            } catch (EncodingException ex) {
                Assert.Fail("Can't decode reDecodedInterest");
            }
            ArrayList redecodedDump = dumpInterest(reDecodedInterest);
            Assert.AssertTrue("Re-decoded interest does not match original",
                    interestDumpsEqual(dump, redecodedDump));
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:23,代码来源:TestInterestMethods.cs

示例11: testMatchesData

        public void testMatchesData()
        {
            Interest interest = new Interest(new Name("/A"));
            interest.setMinSuffixComponents(2);
            interest.setMaxSuffixComponents(2);
            interest.getKeyLocator().setType(net.named_data.jndn.KeyLocatorType.KEYNAME);
            interest.getKeyLocator().setKeyName(new Name("/B"));
            interest.getExclude().appendComponent(new Name.Component("J"));
            interest.getExclude().appendAny();

            Data data = new Data(new Name("/A/D"));
            Sha256WithRsaSignature signature = new Sha256WithRsaSignature();
            signature.getKeyLocator().setType(net.named_data.jndn.KeyLocatorType.KEYNAME);
            signature.getKeyLocator().setKeyName(new Name("/B"));
            data.setSignature(signature);
            Assert.AssertEquals(true, interest.matchesData(data));

            // Check violating MinSuffixComponents.
            Data data1 = new Data(data);
            data1.setName(new Name("/A"));
            Assert.AssertEquals(false, interest.matchesData(data1));

            Interest interest1 = new Interest(interest);
            interest1.setMinSuffixComponents(1);
            Assert.AssertEquals(true, interest1.matchesData(data1));

            // Check violating MaxSuffixComponents.
            Data data2 = new Data(data);
            data2.setName(new Name("/A/E/F"));
            Assert.AssertEquals(false, interest.matchesData(data2));

            Interest interest2 = new Interest(interest);
            interest2.setMaxSuffixComponents(3);
            Assert.AssertEquals(true, interest2.matchesData(data2));

            // Check violating PublisherPublicKeyLocator.
            Data data3 = new Data(data);
            Sha256WithRsaSignature signature3 = new Sha256WithRsaSignature();
            signature3.getKeyLocator().setType(net.named_data.jndn.KeyLocatorType.KEYNAME);
            signature3.getKeyLocator().setKeyName(new Name("/G"));
            data3.setSignature(signature3);
            Assert.AssertEquals(false, interest.matchesData(data3));

            Interest interest3 = new Interest(interest);
            interest3.getKeyLocator().setType(net.named_data.jndn.KeyLocatorType.KEYNAME);
            interest3.getKeyLocator().setKeyName(new Name("/G"));
            Assert.AssertEquals(true, interest3.matchesData(data3));

            Data data4 = new Data(data);
            data4.setSignature(new DigestSha256Signature());
            Assert.AssertEquals(false, interest.matchesData(data4));

            Interest interest4 = new Interest(interest);
            interest4.setKeyLocator(new KeyLocator());
            Assert.AssertEquals(true, interest4.matchesData(data4));

            // Check violating Exclude.
            Data data5 = new Data(data);
            data5.setName(new Name("/A/J"));
            Assert.AssertEquals(false, interest.matchesData(data5));

            Interest interest5 = new Interest(interest);
            interest5.getExclude().clear();
            interest5.getExclude().appendComponent(new Name.Component("K"));
            interest5.getExclude().appendAny();
            Assert.AssertEquals(true, interest5.matchesData(data5));

            // Check violating Name.
            Data data6 = new Data(data);
            data6.setName(new Name("/H/I"));
            Assert.AssertEquals(false, interest.matchesData(data6));

            Data data7 = new Data(data);
            data7.setName(new Name("/A/B"));

            Interest interest7 = new Interest(
                    new Name(
                            "/A/B/sha256digest="
                                    + "54008e240a7eea2714a161dfddf0dd6ced223b3856e9da96792151e180f3b128"));
            Assert.AssertEquals(true, interest7.matchesData(data7));

            // Check violating the implicit digest.
            Interest interest7b = new Interest(new Name(
                    "/A/B/%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00"
                            + "%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00"));
            Assert.AssertEquals(false, interest7b.matchesData(data7));

            // Check excluding the implicit digest.
            Interest interest8 = new Interest(new Name("/A/B"));
            interest8.getExclude().appendComponent(interest7.getName().get(2));
            Assert.AssertEquals(false, interest8.matchesData(data7));
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:92,代码来源:TestInterestMethods.cs


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