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


C# Name.toUri方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            try {
            var face = new Face
              (new TcpTransport(), new TcpTransport.ConnectionInfo("localhost"));

            var counter = new Counter1();

            Console.Out.WriteLine("Enter a word to echo:");
            var word = Console.In.ReadLine();

            var name = new Name("/testecho");
            name.append(word);
            Console.Out.WriteLine("Express name " + name.toUri());
            face.expressInterest(name, counter, counter);

            // The main event loop.
            while (counter.callbackCount_ < 1) {
              face.processEvents();

              // We need to sleep for a few milliseconds so we don't use 100% of the CPU.
              System.Threading.Thread.Sleep(5);
            }
              } catch (Exception e) {
            Console.Out.WriteLine("exception: " + e.Message);
              }
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:27,代码来源:test-echo-consumer.cs

示例2: Main

        static void Main(string[] args)
        {
            try {
            var face = new Face("aleph.ndn.ucla.edu");

            var counter = new Counter();

            // Try to fetch anything.
            var name1 = new Name("/");
            Console.Out.WriteLine("Express name " + name1.toUri());
            face.expressInterest(name1, counter, counter);

            // Try to fetch using a known name.
            var name2 = new Name("/ndn/edu/ucla/remap/demo/ndn-js-test/hello.txt/%FDU%8D%9DM");
            Console.Out.WriteLine("Express name " + name2.toUri());
            face.expressInterest(name2, counter, counter);

            // Expect this to time out.
            var name3 = new Name("/test/timeout");
            Console.Out.WriteLine("Express name " + name3.toUri());
            face.expressInterest(name3, counter, counter);

            // The main event loop.
            while (counter.callbackCount_ < 3) {
              face.processEvents();
              // We need to sleep for a few milliseconds so we don't use 100% of the CPU.
              System.Threading.Thread.Sleep(5);
            }
              } catch (Exception e) {
            Console.Out.WriteLine("exception: " + e.Message);
              }
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:32,代码来源:test-get-async.cs

示例3: deleteKeyPair

        /// <summary>
        /// Delete a pair of asymmetric keys. If the key doesn't exist, do nothing.
        /// </summary>
        ///
        /// <param name="keyName">The name of the key pair.</param>
        public override void deleteKeyPair(Name keyName)
        {
            String keyUri = keyName.toUri();

            ILOG.J2CsMapping.Collections.Collections.Remove(publicKeyStore_,keyUri);
            ILOG.J2CsMapping.Collections.Collections.Remove(privateKeyStore_,keyUri);
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:12,代码来源:MemoryPrivateKeyStorage.cs

示例4: match

        /// <summary>
        /// Determine if the provided NDN regex matches the given Name.
        /// </summary>
        ///
        /// <param name="pattern">The NDN regex.</param>
        /// <param name="name">The Name to match against the regex.</param>
        /// <returns>The Matcher object from Pattern.matcher after the first find, or
        /// null if the pattern does not match.</returns>
        public static Matcher match(String pattern, Name name)
        {
            String nameUri = name.toUri();

            pattern = sanitizeSets(pattern);

            pattern = pattern.Replace("<>", "(?:<.+?>)");
            pattern = pattern.Replace(">", "");
            // Explicitly use regex replace for portability.
            pattern = ILOG.J2CsMapping.Text.Pattern.Compile("<(?!!)").Matcher(pattern).replaceAll("/");

            Matcher match = ILOG.J2CsMapping.Text.Pattern.Compile(pattern).Matcher(nameUri);
            if (match.Find())
                return match;
            else
                return null;
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:25,代码来源:NdnRegexMatcher.cs

示例5: getCertificate

        /// <summary>
        /// Fetch a certificate from the cache.
        /// </summary>
        ///
        /// <param name="certificateName"></param>
        /// <returns>A new copy of the IdentityCertificate, or null if not found.</returns>
        public IdentityCertificate getCertificate(Name certificateName)
        {
            Blob certData = (Blob) ILOG.J2CsMapping.Collections.Collections.Get(cache_,certificateName.toUri());
            if (certData == null)
                return null;

            IdentityCertificate cert = new IdentityCertificate();
            try {
                cert.wireDecode(certData.buf());
            } catch (EncodingException ex) {
                ILOG.J2CsMapping.Util.Logging.Logger.getLogger(typeof(CertificateCache).FullName).log(
                        ILOG.J2CsMapping.Util.Logging.Level.SEVERE, null, ex);
                throw new Exception(ex.Message);
            }

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

示例6: getKey

        /// <summary>
        /// Get the public key DER blob from the identity storage.
        /// </summary>
        ///
        /// <param name="keyName">The name of the requested public key.</param>
        /// <returns>The DER Blob.</returns>
        /// <exception cref="System.Security.SecurityException">if the key doesn't exist.</exception>
        public override Blob getKey(Name keyName)
        {
            if (keyName.size() == 0)
                throw new SecurityException(
                        "MemoryIdentityStorage::getKey: Empty keyName");

            MemoryIdentityStorage.KeyRecord  keyRecord = (MemoryIdentityStorage.KeyRecord ) ILOG.J2CsMapping.Collections.Collections.Get(keyStore_,keyName.toUri());
            if (keyRecord == null)
                throw new SecurityException(
                        "MemoryIdentityStorage::getKey: The key does not exist");

            return keyRecord.getKeyDer();
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:20,代码来源:MemoryIdentityStorage.cs

示例7: setPrivateKeyForKeyName

        /// <summary>
        /// Set the private key for the keyName.
        /// </summary>
        ///
        /// <param name="keyName">The key name.</param>
        /// <param name="keyType">The KeyType, such as KeyType.RSA.</param>
        /// <param name="privateKeyDer">The private key DER byte buffer.</param>
        /// <exception cref="System.Security.SecurityException">if can't decode the key DER.</exception>
        public void setPrivateKeyForKeyName(Name keyName, KeyType keyType,
				ByteBuffer privateKeyDer)
        {
            ILOG.J2CsMapping.Collections.Collections.Put(privateKeyStore_,keyName.toUri(),new MemoryPrivateKeyStorage.PrivateKey (keyType,
                            privateKeyDer));
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:14,代码来源:MemoryPrivateKeyStorage.cs

示例8: certificateNameToPublicKeyName

        /// <summary>
        /// Get the public key name from the full certificate name.
        /// </summary>
        ///
        /// <param name="certificateName">The full certificate name.</param>
        /// <returns>The related public key name.</returns>
        public static Name certificateNameToPublicKeyName(Name certificateName)
        {
            String idString = "ID-CERT";
            bool foundIdString = false;
            int idCertComponentIndex = certificateName.size() - 1;
            for (; idCertComponentIndex + 1 > 0; --idCertComponentIndex) {
                if (certificateName.get(idCertComponentIndex).toEscapedString()
                        .equals(idString)) {
                    foundIdString = true;
                    break;
                }
            }

            if (!foundIdString)
                throw new Exception("Incorrect identity certificate name "
                        + certificateName.toUri());

            Name tempName = certificateName.getSubName(0, idCertComponentIndex);
            String keyString = "KEY";
            bool foundKeyString = false;
            int keyComponentIndex = 0;
            for (; keyComponentIndex < tempName.size(); keyComponentIndex++) {
                if (tempName.get(keyComponentIndex).toEscapedString()
                        .equals(keyString)) {
                    foundKeyString = true;
                    break;
                }
            }

            if (!foundKeyString)
                throw new Exception("Incorrect identity certificate name "
                        + certificateName.toUri());

            return tempName.getSubName(0, keyComponentIndex).append(
                    tempName.getSubName(keyComponentIndex + 1, tempName.size()
                            - keyComponentIndex - 1));
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:43,代码来源:IdentityCertificate.cs

示例9: registerPrefix

        /// <summary>
        /// Call registerPrefix on the Face given to the constructor so that this
        /// MemoryContentCache will answer interests whose name has the prefix.
        /// Alternatively, if the Face's registerPrefix has already been called, then
        /// you can call this object's setInterestFilter.
        /// </summary>
        ///
        /// <param name="prefix">The Name for the prefix to register. This copies the Name.</param>
        /// <param name="onRegisterFailed">NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onRegisterSuccess">receives a success message from the forwarder. If onRegisterSuccess is null, this does not use it. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onDataNotFound">onDataNotFound.onInterest(prefix, interest, face, interestFilterId, filter). Your callback can find the Data packet for the interest and call face.putData(data).  If your callback cannot find the Data packet, it can optionally call storePendingInterest(interest, face) to store the pending interest in this object to be satisfied by a later call to add(data). If you want to automatically store all pending interests, you can simply use getStorePendingInterest() for onDataNotFound. If onDataNotFound is null, this does not use it. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="flags">See Face.registerPrefix.</param>
        /// <param name="wireFormat">See Face.registerPrefix.</param>
        /// <exception cref="IOException">For I/O error in sending the registration request.</exception>
        /// <exception cref="System.Security.SecurityException">If signing a command interest for NFD and cannotfind the private key for the certificateName.</exception>
        public void registerPrefix(Name prefix,
				OnRegisterFailed onRegisterFailed,
				OnRegisterSuccess onRegisterSuccess,
				OnInterestCallback onDataNotFound, ForwardingFlags flags,
				WireFormat wireFormat)
        {
            if (onDataNotFound != null)
                ILOG.J2CsMapping.Collections.Collections.Put(onDataNotFoundForPrefix_,prefix.toUri(),onDataNotFound);
            long registeredPrefixId = face_.registerPrefix(prefix, this,
                    onRegisterFailed, onRegisterSuccess, flags, wireFormat);
            ILOG.J2CsMapping.Collections.Collections.Add(registeredPrefixIdList_,registeredPrefixId);
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:27,代码来源:MemoryContentCache.cs

示例10: testAppend

        public void testAppend()
        {
            // could possibly split this into different tests
            String uri = "/localhost/user/folders/files/%00%0F";
            Name name = new Name(uri);
            Name name2 = new Name("/localhost").append(new Name("/user/folders/"));
            Assert.AssertEquals("Name constructed by appending names has " + name2.size()
                    + " components instead of 3", 3, name2.size());
            Assert.AssertTrue("Name constructed with append has wrong suffix", name2
                    .get(2).getValue().equals(new Blob("folders")));
            name2 = name2.append("files");
            Assert.AssertEquals("Name constructed by appending string has " + name2.size()
                    + " components instead of 4", 4, name2.size());
            name2 = name2.appendSegment(15);
            Assert.AssertTrue(
                    "Name constructed by appending segment has wrong segment value",
                    name2.get(4).getValue()
                            .equals(new Blob(new int[] { 0x00, 0x0F })));

            Assert.AssertTrue(
                    "Name constructed with append is not equal to URI constructed name",
                    name2.equals(name));
            Assert.AssertEquals("Name constructed with append has wrong URI",
                    name.toUri(), name2.toUri());
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:25,代码来源:TestNameMethods.cs

示例11: deleteCertificate

 /// <summary>
 /// Remove a certificate from the cache. This does nothing if it is not present.
 /// </summary>
 ///
 /// <param name="certificateName"></param>
 public void deleteCertificate(Name certificateName)
 {
     ILOG.J2CsMapping.Collections.Collections.Remove(cache_,certificateName.toUri());
 }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:9,代码来源:CertificateCache.cs

示例12: addKey

        /// <summary>
        /// Add a public key to the identity storage. Also call addIdentity to ensure
        /// that the identityName for the key exists. However, if the key already
        /// exists, do nothing.
        /// </summary>
        ///
        /// <param name="keyName">The name of the public key to be added.</param>
        /// <param name="keyType">Type of the public key to be added.</param>
        /// <param name="publicKeyDer">A blob of the public key DER to be added.</param>
        public override void addKey(Name keyName, KeyType keyType, Blob publicKeyDer)
        {
            if (keyName.size() == 0)
                return;

            if (doesKeyExist(keyName))
                return;

            Name identityName = keyName.getSubName(0, keyName.size() - 1);

            addIdentity(identityName);

            ILOG.J2CsMapping.Collections.Collections.Put(keyStore_,keyName.toUri(),new MemoryIdentityStorage.KeyRecord (keyType, publicKeyDer));
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:23,代码来源:MemoryIdentityStorage.cs

示例13: addIdentity

        /// <summary>
        /// Add a new identity. Do nothing if the identity already exists.
        /// </summary>
        ///
        /// <param name="identityName">The identity name to be added.</param>
        public override void addIdentity(Name identityName)
        {
            String identityUri = identityName.toUri();
            if (identityStore_.Contains(identityUri))
                return;

            ILOG.J2CsMapping.Collections.Collections.Put(identityStore_,identityUri,new MemoryIdentityStorage.IdentityRecord ());
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:13,代码来源:MemoryIdentityStorage.cs

示例14: selfSign

        /// <summary>
        /// Generate a self-signed certificate for a public key.
        /// </summary>
        ///
        /// <param name="keyName">The name of the public key.</param>
        /// <returns>The generated certificate.</returns>
        public IdentityCertificate selfSign(Name keyName)
        {
            IdentityCertificate certificate = new IdentityCertificate();

            Blob keyBlob = identityStorage_.getKey(keyName);
            PublicKey publicKey = new PublicKey(keyBlob);

            Calendar calendar = ILOG.J2CsMapping.Util.Calendar.getInstance();
            double notBefore = (double) calendar.getTimeInMillis();
            calendar.add(ILOG.J2CsMapping.Util.Calendar.YEAR, 2);
            double notAfter = (double) calendar.getTimeInMillis();

            certificate.setNotBefore(notBefore);
            certificate.setNotAfter(notAfter);

            Name certificateName = keyName.getPrefix(-1).append("KEY")
                    .append(keyName.get(-1)).append("ID-CERT")
                    .appendVersion((long) certificate.getNotBefore());
            certificate.setName(certificateName);

            certificate.setPublicKeyInfo(publicKey);
            certificate.addSubjectDescription(new CertificateSubjectDescription(
                    "2.5.4.41", keyName.toUri()));
            try {
                certificate.encode();
            } catch (DerEncodingException ex) {
                // We don't expect this to happen.
                ILOG.J2CsMapping.Util.Logging.Logger.getLogger(typeof(IdentityManager).FullName).log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE,
                        null, ex);
                return null;
            } catch (DerDecodingException ex_0) {
                // We don't expect this to happen.
                ILOG.J2CsMapping.Util.Logging.Logger.getLogger(typeof(IdentityManager).FullName).log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE,
                        null, ex_0);
                return null;
            }

            signByCertificate(certificate, certificate.getName());

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

示例15: doesKeyExist

 /// <summary>
 /// Check if a particular key exists.
 /// </summary>
 ///
 /// <param name="keyName">The name of the key.</param>
 /// <param name="keyClass"></param>
 /// <returns>True if the key exists, otherwise false.</returns>
 public override bool doesKeyExist(Name keyName, KeyClass keyClass)
 {
     if (keyClass == net.named_data.jndn.security.KeyClass.PUBLIC)
         return publicKeyStore_.Contains(keyName.toUri());
     else if (keyClass == net.named_data.jndn.security.KeyClass.PRIVATE)
         return privateKeyStore_.Contains(keyName.toUri());
     else
         // KeyClass.SYMMETRIC not implemented yet.
         return false;
 }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:17,代码来源:MemoryPrivateKeyStorage.cs


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