本文整理汇总了C#中net.named_data.jndn.Interest类的典型用法代码示例。如果您正苦于以下问题:C# Interest类的具体用法?C# Interest怎么用?C# Interest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Interest类属于net.named_data.jndn命名空间,在下文中一共展示了Interest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: checkVerificationPolicy
public ValidationRequest checkVerificationPolicy(Interest interest,
int stepCount, OnVerifiedInterest onVerified,
OnInterestValidationFailed onValidationFailed)
{
return checkVerificationPolicy(interest, stepCount, onVerified,
onValidationFailed, net.named_data.jndn.encoding.WireFormat.getDefaultWireFormat());
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:7,代码来源:PolicyManager.cs
示例2: 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
示例3: expressInterest
/// <summary>
/// Override to submit a task to use the thread pool given to the constructor.
/// Also wrap the supplied onData, onTimeout and onNetworkNack callbacks in an
/// outer callback which submits a task to the thread pool to call the supplied
/// callback. See Face.expressInterest for calling details.
/// </summary>
///
public override long expressInterest(Interest interest_0, OnData onData,
OnTimeout onTimeout, OnNetworkNack onNetworkNack,
WireFormat wireFormat_1)
{
long pendingInterestId_2 = node_.getNextEntryId();
// Wrap callbacks to submit to the thread pool.
OnData finalOnData_3 = onData;
OnData onDataSubmit_4 = new ThreadPoolFace.Anonymous_C14 (this, finalOnData_3);
OnTimeout finalOnTimeout_5 = onTimeout;
OnTimeout onTimeoutSubmit_6 = (onTimeout == null) ? null
: new ThreadPoolFace.Anonymous_C13 (this, finalOnTimeout_5);
OnNetworkNack finalOnNetworkNack_7 = onNetworkNack;
OnNetworkNack onNetworkNackSubmit_8 = (onNetworkNack == null) ? null
: new ThreadPoolFace.Anonymous_C12 (this, finalOnNetworkNack_7);
// Make an interest copy as required by Node.expressInterest.
Interest interestCopy_9 = new Interest(interest_0);
threadPool_.submit(new ThreadPoolFace.Anonymous_C11 (this, onNetworkNackSubmit_8, onDataSubmit_4,
interestCopy_9, onTimeoutSubmit_6, pendingInterestId_2, wireFormat_1));
return pendingInterestId_2;
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:32,代码来源:ThreadPoolFace.cs
示例4: testMaxNdnPacketSize
public void testMaxNdnPacketSize()
{
// Construct an interest whose encoding is one byte larger than getMaxNdnPacketSize.
int targetSize = net.named_data.jndn.Face.getMaxNdnPacketSize() + 1;
// Start with an interest which is almost the right size.
Interest interest = new Interest();
interest.getName().append(new byte[targetSize]);
int initialSize = interest.wireEncode().size();
// Now replace the component with the desired size which trims off the extra encoding.
interest.setName(new Name().append(new byte[targetSize
- (initialSize - targetSize)]));
int interestSize = interest.wireEncode().size();
AssertEquals("Wrong interest size for MaxNdnPacketSize", targetSize,
interestSize);
CallbackCounter counter = new CallbackCounter();
bool gotError = true;
try {
face.expressInterest(interest, counter, counter);
gotError = false;
} catch (Exception ex) {
}
if (!gotError)
Fail("expressInterest didn't throw an exception when the interest size exceeds getMaxNdnPacketSize()");
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:25,代码来源:TestFaceInterestMethods.cs
示例5: getMatchedFilters
public void getMatchedFilters(Interest interest,
ArrayList matchedFilters)
{
for (int i = 0; i < table_.Count; ++i) {
InterestFilterTable.Entry entry = table_[i];
if (entry.getFilter().doesMatch(interest.getName()))
ILOG.J2CsMapping.Collections.Collections.Add(matchedFilters,entry);
}
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:9,代码来源:InterestFilterTable.cs
示例6: ValidationRequest
public ValidationRequest(Interest interest, OnVerified onVerified,
OnDataValidationFailed onValidationFailed, int retry, int stepCount)
{
interest_ = interest;
onVerified_ = onVerified;
onValidationFailed_ = onValidationFailed;
retry_ = retry;
stepCount_ = stepCount;
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:9,代码来源:ValidationRequest.cs
示例7: setUp
public void setUp()
{
referenceInterest = new Interest();
try {
referenceInterest.wireDecode(new Blob(codedInterest, false));
} catch (EncodingException ex) {
// We don't expect this to happen.
referenceInterest = null;
}
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:10,代码来源:TestInterestMethods.cs
示例8: checkVerificationPolicy
/// <summary>
/// Override to call onVerified.onVerifiedInterest(interest) and to indicate no
/// further verification step.
/// </summary>
///
/// <param name="interest">The interest with the signature (to ignore).</param>
/// <param name="stepCount"></param>
/// <param name="onVerified">better error handling the callback should catch and properly handle any exceptions.</param>
/// <param name="onValidationFailed">Override to ignore this.</param>
/// <returns>null for no further step.</returns>
public override sealed ValidationRequest checkVerificationPolicy(Interest interest,
int stepCount, OnVerifiedInterest onVerified,
OnInterestValidationFailed onValidationFailed, WireFormat wireFormat)
{
try {
onVerified.onVerifiedInterest(interest);
} catch (Exception ex) {
logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onVerifiedInterest", ex);
}
return null;
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:21,代码来源:NoVerifyPolicyManager.cs
示例9: add
public PendingInterestTable.Entry add(long pendingInterestId,
Interest interestCopy, OnData onData, OnTimeout onTimeout,
OnNetworkNack onNetworkNack)
{
int removeRequestIndex = removeRequests_.indexOf(pendingInterestId);
if (removeRequestIndex >= 0) {
// removePendingInterest was called with the pendingInterestId returned by
// expressInterest before we got here, so don't add a PIT entry.
ILOG.J2CsMapping.Collections.Collections.RemoveAt(removeRequests_,removeRequestIndex);
return null;
}
PendingInterestTable.Entry entry = new PendingInterestTable.Entry (pendingInterestId, interestCopy, onData,
onTimeout, onNetworkNack);
ILOG.J2CsMapping.Collections.Collections.Add(table_,entry);
return entry;
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:17,代码来源:PendingInterestTable.cs
示例10: checkVerificationPolicy
/// <summary>
/// Use wireFormat.decodeSignatureInfoAndValue to decode the last two name
/// components of the signed interest. Look in the IdentityStorage for the
/// public key with the name in the KeyLocator (if available) and use it to
/// verify the interest. If the public key can't be found, call onVerifyFailed.
/// </summary>
///
/// <param name="interest">The interest with the signature to check.</param>
/// <param name="stepCount"></param>
/// <param name="onVerified">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="onValidationFailed">onValidationFailed.onInterestValidationFailed(interest, reason). 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>
/// <returns>null for no further step for looking up a certificate chain.</returns>
public override ValidationRequest checkVerificationPolicy(Interest interest,
int stepCount, OnVerifiedInterest onVerified,
OnInterestValidationFailed onValidationFailed, WireFormat wireFormat)
{
if (interest.getName().size() < 2) {
try {
onValidationFailed.onInterestValidationFailed(interest,
"The signed interest has less than 2 components: "
+ interest.getName().toUri());
} catch (Exception exception) {
logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE,
"Error in onInterestValidationFailed", exception);
}
return null;
}
// Decode the last two name components of the signed interest
Signature signature;
try {
signature = wireFormat.decodeSignatureInfoAndValue(interest
.getName().get(-2).getValue().buf(), interest.getName()
.get(-1).getValue().buf(), false);
} catch (EncodingException ex) {
logger_.log(
ILOG.J2CsMapping.Util.Logging.Level.INFO,
"Cannot decode the signed interest SignatureInfo and value",
ex);
try {
onValidationFailed.onInterestValidationFailed(interest,
"Error decoding the signed interest signature: " + ex);
} catch (Exception exception_0) {
logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE,
"Error in onInterestValidationFailed", exception_0);
}
return null;
}
String[] failureReason = new String[] { "unknown" };
// wireEncode returns the cached encoding if available.
if (verify(signature, interest.wireEncode(wireFormat), failureReason)) {
try {
onVerified.onVerifiedInterest(interest);
} catch (Exception ex_1) {
logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onVerifiedInterest", ex_1);
}
} else {
try {
onValidationFailed.onInterestValidationFailed(interest,
failureReason[0]);
} catch (Exception ex_2) {
logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE,
"Error in onInterestValidationFailed", ex_2);
}
}
// No more steps, so return a null ValidationRequest.
return null;
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:70,代码来源:SelfVerifyPolicyManager.cs
示例11: onVerifiedInterest
public void onVerifiedInterest(Interest interest)
{
Console.Out.WriteLine(prefix_ + " signature verification: VERIFIED");
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:4,代码来源:test-encode-decode-interest.cs
示例12: onInterestValidationFailed
public void onInterestValidationFailed(Interest interest, string reason)
{
Console.Out.WriteLine
(prefix_ + " signature verification: FAILED. Reason: " + reason);
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:5,代码来源:test-encode-decode-interest.cs
示例13: 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
示例14: 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
示例15: onTimeout
public virtual void onTimeout(Interest interest)
{
interest_ = interest;
++onTimeoutCallCount_;
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:5,代码来源:TestFaceInterestMethods.cs
示例16: onData
public virtual void onData(Interest interest, Data data)
{
interest_ = interest;
data_ = data;
++onDataCallCount_;
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:6,代码来源:TestFaceInterestMethods.cs
示例17: requireVerify
/// <summary>
/// Always return true to use the self-verification rule for the received interest.
/// </summary>
///
/// <param name="interest">The received interest.</param>
/// <returns>true.</returns>
public override bool requireVerify(Interest interest)
{
return true;
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:10,代码来源:SelfVerifyPolicyManager.cs
示例18: expressInterest
/// <summary>
/// Encode name as an Interest. If interestTemplate is not null, use its
/// interest selectors.
/// Send the Interest through the transport, read the entire response and call
/// onData as described below.
/// Ignore if the interest times out.
/// </summary>
///
/// <param name="name">A Name for the interest. This copies the Name.</param>
/// <param name="interestTemplate"></param>
/// <param name="onData">expressInterest and data is the received Data object. NOTE: You must not change the interest object - if you need to change it then make a copy. 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="wireFormat">A WireFormat object used to encode the message.</param>
/// <returns>The pending interest ID which can be used with
/// removePendingInterest.</returns>
/// <exception cref="IOException">For I/O error in sending the interest.</exception>
/// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
public long expressInterest(Name name, Interest interestTemplate,
OnData onData, WireFormat wireFormat)
{
return expressInterest(name, interestTemplate, onData, null, wireFormat);
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:21,代码来源:Face.cs
示例19: skipVerifyAndTrust
/// <summary>
/// Never skip verification.
/// </summary>
///
/// <param name="interest">The received interest.</param>
/// <returns>false.</returns>
public override bool skipVerifyAndTrust(Interest interest)
{
return false;
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:10,代码来源:SelfVerifyPolicyManager.cs
示例20: makeCommandInterest
/// <summary>
/// Append a timestamp component and a random value component to interest's
/// name. Then use the keyChain and certificateName from setCommandSigningInfo
/// to sign the interest. If the interest lifetime is not set, this sets it.
/// </summary>
///
/// <param name="interest">The interest whose name is appended with components.</param>
/// <param name="wireFormat"></param>
/// <exception cref="System.Security.SecurityException">If cannot find the private key for thecertificateName.</exception>
/// @note This method is an experimental feature. See the API docs for more detail at
/// http://named-data.net/doc/ndn-ccl-api/face.html#face-makecommandinterest-method .
public void makeCommandInterest(Interest interest, WireFormat wireFormat)
{
node_.makeCommandInterest(interest, commandKeyChain_,
commandCertificateName_, wireFormat);
}
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:16,代码来源:Face.cs
注:本文中的net.named_data.jndn.Interest类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论