本文整理汇总了C#中net.named_data.jndn.Name类的典型用法代码示例。如果您正苦于以下问题:C# Name类的具体用法?C# Name怎么用?C# Name使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Name类属于net.named_data.jndn命名空间,在下文中一共展示了Name类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: Name
/// <summary>
/// Create a new Name with the components in the given name.
/// </summary>
///
/// <param name="name">The name with components to copy from.</param>
public Name(Name name)
{
this.changeCount_ = 0;
this.haveHashCode_ = false;
this.hashCodeChangeCount_ = 0;
components_ = new ArrayList<Component>(name.components_);
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:12,代码来源:Name.cs
示例3: Link
/// <summary>
/// Create a Link with the given name and default values and where the list of
/// delegations is empty and the meta info type is LINK.
/// </summary>
///
/// <param name="name">The name which is copied.</param>
public Link(Name name)
: base(name)
{
this.delegations_ = new DelegationSet();
getMetaInfo().setType(net.named_data.jndn.ContentType.LINK);
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:13,代码来源:Link.cs
示例4: 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
示例5: 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
示例6: generate
/// <summary>
/// Append a timestamp component and a random value component to interest's
/// name. This ensures that the timestamp is greater than the timestamp used in
/// the previous call. Then use keyChain to sign the interest which appends a
/// SignatureInfo component and a component with the signature bits. If the
/// interest lifetime is not set, this sets it.
/// </summary>
///
/// <param name="interest">The interest whose name is append with components.</param>
/// <param name="keyChain">The KeyChain for calling sign.</param>
/// <param name="certificateName">The certificate name of the key to use for signing.</param>
/// <param name="wireFormat"></param>
public void generate(Interest interest, KeyChain keyChain,
Name certificateName, WireFormat wireFormat)
{
double timestamp;
lock (lastTimestampLock_) {
timestamp = Math.Round(net.named_data.jndn.util.Common.getNowMilliseconds(),MidpointRounding.AwayFromZero);
while (timestamp <= lastTimestamp_)
timestamp += 1.0d;
// Update the timestamp now while it is locked. In the small chance that
// signing fails, it just means that we have bumped the timestamp.
lastTimestamp_ = timestamp;
}
// The timestamp is encoded as a TLV nonNegativeInteger.
TlvEncoder encoder = new TlvEncoder(8);
encoder.writeNonNegativeInteger((long) timestamp);
interest.getName().append(new Blob(encoder.getOutput(), false));
// The random value is a TLV nonNegativeInteger too, but we know it is 8 bytes,
// so we don't need to call the nonNegativeInteger encoder.
ByteBuffer randomBuffer = ILOG.J2CsMapping.NIO.ByteBuffer.allocate(8);
// Note: SecureRandom is thread safe.
net.named_data.jndn.util.Common.getRandom().nextBytes(randomBuffer.array());
interest.getName().append(new Blob(randomBuffer, false));
keyChain.sign(interest, certificateName, wireFormat);
if (interest.getInterestLifetimeMilliseconds() < 0)
// The caller has not set the interest lifetime, so set it here.
interest.setInterestLifetimeMilliseconds(1000.0d);
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:43,代码来源:CommandInterestGenerator.cs
示例7: 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
示例8: Interest
/// <summary>
/// Create a new Interest with the given name and interest lifetime and "none"
/// for other values.
/// </summary>
///
/// <param name="name">The name for the interest.</param>
/// <param name="interestLifetimeMilliseconds"></param>
public Interest(Name name, double interestLifetimeMilliseconds)
{
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;
if (name != null)
name_.set(new Name(name));
interestLifetimeMilliseconds_ = interestLifetimeMilliseconds;
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:32,代码来源:Interest.cs
示例9: Face
/// <summary>
/// Create a new Face for communication with an NDN hub at host using the
/// default port 6363 and the default TcpTransport.
/// </summary>
///
/// <param name="host">The host of the NDN hub.</param>
public Face(String host)
{
this.commandKeyChain_ = null;
this.commandCertificateName_ = new Name();
node_ = new Node(new TcpTransport(), new TcpTransport.ConnectionInfo(
host, 6363));
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:13,代码来源:Face.cs
示例10: testCompare
public void testCompare()
{
Name.Component c7f = new Name("/%7F").get(0);
Name.Component c80 = new Name("/%80").get(0);
Name.Component c81 = new Name("/%81").get(0);
Assert.AssertTrue("%81 should be greater than %80", c81.compare(c80) > 0);
Assert.AssertTrue("%80 should be greater than %7f", c80.compare(c7f) > 0);
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:9,代码来源:TestNameComponentMethods.cs
示例11: IdentityCertificate
/// <summary>
/// Create an IdentityCertificate from the content in the data packet.
/// </summary>
///
/// <param name="data">The data packet with the content to decode.</param>
public IdentityCertificate(Data data)
: base(data)
{
this.publicKeyName_ = new Name();
if (!isCorrectName(data.getName()))
throw new SecurityException("Wrong Identity Certificate Name!");
setPublicKeyName();
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:15,代码来源:IdentityCertificate.cs
示例12: setUp
public void setUp()
{
Name[] localCertificateName = new Name[1];
keyChain = net.named_data.jndn.tests.integration_tests.IntegrationTestsCommon.buildKeyChain(localCertificateName);
certificateName = localCertificateName[0];
faceIn = net.named_data.jndn.tests.integration_tests.IntegrationTestsCommon.buildFaceWithKeyChain("localhost",
keyChain, certificateName);
faceOut = net.named_data.jndn.tests.integration_tests.IntegrationTestsCommon.buildFaceWithKeyChain("localhost",
keyChain, certificateName);
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:11,代码来源:TestFaceCallRegisterMethods.cs
示例13: GroupManager
/// <summary>
/// Create a group manager with the given values. The group manager namespace
/// is /{prefix}/read/{dataType} .
/// </summary>
///
/// <param name="prefix">The prefix for the group manager namespace.</param>
/// <param name="dataType">The data type for the group manager namespace.</param>
/// <param name="database"></param>
/// <param name="keySize">The group key will be an RSA key with keySize bits.</param>
/// <param name="freshnessHours"></param>
/// <param name="keyChain"></param>
public GroupManager(Name prefix, Name dataType, GroupManagerDb database,
int keySize, int freshnessHours, KeyChain keyChain)
{
namespace_ = new Name(prefix).append(net.named_data.jndn.encrypt.algo.Encryptor.NAME_COMPONENT_READ)
.append(dataType);
database_ = database;
keySize_ = keySize;
freshnessHours_ = freshnessHours;
keyChain_ = keyChain;
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:22,代码来源:GroupManager.cs
示例14: encryptData
/// <summary>
/// Prepare an encrypted data packet by encrypting the payload using the key
/// according to the params. In addition, this prepares the encoded
/// EncryptedContent with the encryption result using keyName and params. The
/// encoding is set as the content of the data packet. If params defines an
/// asymmetric encryption algorithm and the payload is larger than the maximum
/// plaintext size, this encrypts the payload with a symmetric key that is
/// asymmetrically encrypted and provided as a nonce in the content of the data
/// packet. The packet's /{dataName}/ is updated to be
/// /{dataName}/FOR/{keyName}
/// </summary>
///
/// <param name="data">The data packet which is updated.</param>
/// <param name="payload">The payload to encrypt.</param>
/// <param name="keyName">The key name for the EncryptedContent.</param>
/// <param name="key">The encryption key value.</param>
/// <param name="params">The parameters for encryption.</param>
public static void encryptData(Data data, Blob payload, Name keyName,
Blob key, EncryptParams paras)
{
data.getName().append(NAME_COMPONENT_FOR).append(keyName);
EncryptAlgorithmType algorithmType = paras.getAlgorithmType();
if (algorithmType == net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.AesCbc
|| algorithmType == net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.AesEcb) {
EncryptedContent content = encryptSymmetric(payload, key, keyName,
paras);
data.setContent(content.wireEncode(net.named_data.jndn.encoding.TlvWireFormat.get()));
} else if (algorithmType == net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.RsaPkcs
|| algorithmType == net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.RsaOaep) {
// Java doesn't have a direct way to get the maximum plain text size, so
// try to encrypt the payload first and catch the error if it is too big.
try {
EncryptedContent content_0 = encryptAsymmetric(payload, key,
keyName, paras);
data.setContent(content_0.wireEncode(net.named_data.jndn.encoding.TlvWireFormat.get()));
return;
} catch (IllegalBlockSizeException ex) {
// The payload is larger than the maximum plaintext size. Continue.
}
// 128-bit nonce.
ByteBuffer nonceKeyBuffer = ILOG.J2CsMapping.NIO.ByteBuffer.allocate(16);
net.named_data.jndn.util.Common.getRandom().nextBytes(nonceKeyBuffer.array());
Blob nonceKey = new Blob(nonceKeyBuffer, false);
Name nonceKeyName = new Name(keyName);
nonceKeyName.append("nonce");
EncryptParams symmetricParams = new EncryptParams(
net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.AesCbc, net.named_data.jndn.encrypt.algo.AesAlgorithm.BLOCK_SIZE);
EncryptedContent nonceContent = encryptSymmetric(payload, nonceKey,
nonceKeyName, symmetricParams);
EncryptedContent payloadContent = encryptAsymmetric(nonceKey, key,
keyName, paras);
Blob nonceContentEncoding = nonceContent.wireEncode();
Blob payloadContentEncoding = payloadContent.wireEncode();
ByteBuffer content_1 = ILOG.J2CsMapping.NIO.ByteBuffer.allocate(nonceContentEncoding
.size() + payloadContentEncoding.size());
content_1.put(payloadContentEncoding.buf());
content_1.put(nonceContentEncoding.buf());
content_1.flip();
data.setContent(new Blob(content_1, false));
} else
throw new Exception("Unsupported encryption method");
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:71,代码来源:Encryptor.cs
示例15: Consumer
/// <summary>
/// Create a Consumer to use the given ConsumerDb, Face and other values.
/// </summary>
///
/// <param name="face">The face used for data packet and key fetching.</param>
/// <param name="keyChain">The keyChain used to verify data packets.</param>
/// <param name="groupName"></param>
/// <param name="consumerName"></param>
/// <param name="database">The ConsumerDb database for storing decryption keys.</param>
public Consumer(Face face, KeyChain keyChain, Name groupName,
Name consumerName, ConsumerDb database)
{
this.cKeyMap_ = new Hashtable();
this.dKeyMap_ = new Hashtable();
database_ = database;
keyChain_ = keyChain;
face_ = face;
groupName_ = new Name(groupName);
consumerName_ = new Name(consumerName);
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:20,代码来源:Consumer.cs
示例16: ControlParameters
/// <summary>
/// Create a new ControlParameters where all values are unspecified.
/// </summary>
///
public ControlParameters()
{
this.name_ = null;
this.faceId_ = -1;
this.uri_ = "";
this.localControlFeature_ = -1;
this.origin_ = -1;
this.cost_ = -1;
this.flags_ = new ForwardingFlags();
this.strategy_ = new Name();
this.expirationPeriod_ = -1.0d;
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:16,代码来源:ControlParameters.cs
示例17: Data
/// <summary>
/// Create a new Data object with default values and where the signature is a
/// blank Sha256WithRsaSignature.
/// </summary>
///
public Data()
{
this.signature_ = new ChangeCounter(
new Sha256WithRsaSignature());
this.name_ = new ChangeCounter(new Name());
this.metaInfo_ = new ChangeCounter(new MetaInfo());
this.content_ = new Blob();
this.lpPacket_ = null;
this.defaultWireEncoding_ = new SignedBlob();
this.defaultFullName_ = new Name();
this.getDefaultWireEncodingChangeCount_ = 0;
this.changeCount_ = 0;
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:18,代码来源:Data.cs
示例18: testSegment
public void testSegment()
{
Name expected = new Name("/%00%27%10");
Assert.AssertTrue(expected.get(0).isSegment());
long number = 10000;
Assert.AssertEquals("appendSegment did not create the expected component",
expected, new Name().appendSegment(number));
try {
Assert.AssertEquals("toSegment did not return the expected value", number,
expected.get(0).toSegment());
} catch (EncodingException ex) {
Assert.Fail("Error while parsing a nonNegativeInteger: " + ex.Message);
}
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:14,代码来源:TestNameConventions.cs
示例19: Node
/// <summary>
/// Create a new Node for communication with an NDN hub with the given
/// Transport object and connectionInfo.
/// </summary>
///
/// <param name="transport">A Transport object used for communication.</param>
/// <param name="connectionInfo"></param>
public Node(Transport transport, Transport.ConnectionInfo connectionInfo)
{
this.pendingInterestTable_ = new PendingInterestTable();
this.interestFilterTable_ = new InterestFilterTable();
this.registeredPrefixTable_ = new RegisteredPrefixTable(
interestFilterTable_);
this.delayedCallTable_ = new DelayedCallTable();
this.onConnectedCallbacks_ = ILOG.J2CsMapping.Collections.Collections
.synchronizedList(new ArrayList());
this.commandInterestGenerator_ = new CommandInterestGenerator();
this.timeoutPrefix_ = new Name("/local/timeout");
this.lastEntryIdLock_ = new Object();
this.connectStatus_ = net.named_data.jndn.Node.ConnectStatus.UNCONNECTED;
transport_ = transport;
connectionInfo_ = connectionInfo;
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:23,代码来源:Node.cs
示例20: add
/// <summary>
/// Add a new DelegationSet.Delegation to the list of delegations, sorted by
/// preference number then by name. If there is already a delegation with the
/// same name, update its preference, and remove any extra delegations with the
/// same name.
/// </summary>
///
/// <param name="preference">The preference number.</param>
/// <param name="name">The delegation name. This makes a copy of the name.</param>
public void add(int preference, Name name)
{
remove(name);
DelegationSet.Delegation newDelegation = new DelegationSet.Delegation (preference, name);
// Find the index of the first entry where it is not less than newDelegation.
int i = 0;
while (i < delegations_.Count) {
if (delegations_[i].compare(newDelegation) >= 0)
break;
++i;
}
delegations_.Insert(i, newDelegation);
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:25,代码来源:DelegationSet.cs
注:本文中的net.named_data.jndn.Name类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论