本文整理汇总了C#中net.named_data.jndn.Name.equals方法的典型用法代码示例。如果您正苦于以下问题:C# Name.equals方法的具体用法?C# Name.equals怎么用?C# Name.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.named_data.jndn.Name
的用法示例。
在下文中一共展示了Name.equals方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: testCopyConstructor
public void testCopyConstructor()
{
Name name = new Name(expectedURI);
Name name2 = new Name(name);
Assert.AssertTrue("Name from copy constructor does not match original",
name.equals(name2));
}
示例2: 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());
}
示例3: matches
/// <summary>
/// Check if the component matches any of the exclude criteria.
/// </summary>
///
/// <param name="component">The name component to check.</param>
/// <returns>True if the component matches any of the exclude criteria,
/// otherwise false.</returns>
public bool matches(Name.Component component)
{
for (int i = 0; i < entries_.Count; ++i) {
if (get(i).getType() == net.named_data.jndn.Exclude.Type.ANY) {
Exclude.Entry lowerBound = null;
if (i > 0)
lowerBound = get(i - 1);
// Find the upper bound, possibly skipping over multiple ANY in a row.
int iUpperBound;
Exclude.Entry upperBound = null;
for (iUpperBound = i + 1; iUpperBound < entries_.Count; ++iUpperBound) {
if (get(iUpperBound).getType() == net.named_data.jndn.Exclude.Type.COMPONENT) {
upperBound = get(iUpperBound);
break;
}
}
// If lowerBound != null, we already checked component equals lowerBound on the last pass.
// If upperBound != null, we will check component equals upperBound on the next pass.
if (upperBound != null) {
if (lowerBound != null) {
if (component.compare(lowerBound.getComponent()) > 0
&& component.compare(upperBound.getComponent()) < 0)
return true;
} else {
if (component.compare(upperBound.getComponent()) < 0)
return true;
}
// Make i equal iUpperBound on the next pass.
i = iUpperBound - 1;
} else {
if (lowerBound != null) {
if (component.compare(lowerBound.getComponent()) > 0)
return true;
} else
// entries_ has only ANY.
return true;
}
} else {
if (component.equals(get(i).getComponent()))
return true;
}
}
return false;
}
示例4: setDefaultKeyNameForIdentity
/// <summary>
/// Set a key as the default key of an identity. The identity name is inferred
/// from keyName.
/// </summary>
///
/// <param name="keyName">The name of the key.</param>
/// <param name="identityNameCheck"></param>
public override void setDefaultKeyNameForIdentity(Name keyName,
Name identityNameCheck)
{
Name identityName = keyName.getPrefix(-1);
if (identityNameCheck.size() > 0
&& !identityNameCheck.equals(identityName))
throw new SecurityException(
"The specified identity name does not match the key name");
String identity = identityName.toUri();
if (identityStore_.Contains(identity)) {
((MemoryIdentityStorage.IdentityRecord ) ILOG.J2CsMapping.Collections.Collections.Get(identityStore_,identity))
.setDefaultKey(new Name(keyName));
}
}
示例5: prepareUnsignedIdentityCertificate
/// <summary>
/// Prepare an unsigned identity certificate.
/// </summary>
///
/// <param name="keyName">The key name, e.g., `/{identity_name}/ksk-123456`.</param>
/// <param name="publicKey">The public key to sign.</param>
/// <param name="signingIdentity">The signing identity.</param>
/// <param name="notBefore">See IdentityCertificate.</param>
/// <param name="notAfter">See IdentityCertificate.</param>
/// <param name="subjectDescription">on the keyName.</param>
/// <param name="certPrefix">signingIdentity and the subject identity. If the signingIdentity is a prefix of the subject identity, `KEY` will be inserted after the signingIdentity, otherwise `KEY` is inserted after subject identity (i.e., before `ksk-...`).</param>
/// <returns>The unsigned IdentityCertificate, or null if the inputs are invalid.</returns>
public IdentityCertificate prepareUnsignedIdentityCertificate(
Name keyName, PublicKey publicKey, Name signingIdentity,
double notBefore, double notAfter, IList subjectDescription,
Name certPrefix)
{
if (keyName.size() < 1)
return null;
String tempKeyIdPrefix = keyName.get(-1).toEscapedString();
if (tempKeyIdPrefix.Length < 4)
return null;
String keyIdPrefix = tempKeyIdPrefix.Substring(0,(4)-(0));
if (!keyIdPrefix.equals("ksk-") && !keyIdPrefix.equals("dsk-"))
return null;
IdentityCertificate certificate = new IdentityCertificate();
Name certName = new Name();
if (certPrefix == null) {
// No certificate prefix hint, so infer the prefix.
if (signingIdentity.match(keyName))
certName.append(signingIdentity).append("KEY")
.append(keyName.getSubName(signingIdentity.size()))
.append("ID-CERT")
.appendVersion((long) net.named_data.jndn.util.Common.getNowMilliseconds());
else
certName.append(keyName.getPrefix(-1)).append("KEY")
.append(keyName.get(-1)).append("ID-CERT")
.appendVersion((long) net.named_data.jndn.util.Common.getNowMilliseconds());
} else {
// A cert prefix hint is supplied, so determine the cert name.
if (certPrefix.match(keyName) && !certPrefix.equals(keyName))
certName.append(certPrefix).append("KEY")
.append(keyName.getSubName(certPrefix.size()))
.append("ID-CERT")
.appendVersion((long) net.named_data.jndn.util.Common.getNowMilliseconds());
else
return null;
}
certificate.setName(certName);
certificate.setNotBefore(notBefore);
certificate.setNotAfter(notAfter);
certificate.setPublicKeyInfo(publicKey);
if (subjectDescription == null || (subjectDescription.Count==0))
certificate
.addSubjectDescription(new CertificateSubjectDescription(
"2.5.4.41", keyName.getPrefix(-1).toUri()));
else {
for (int i = 0; i < subjectDescription.Count; ++i)
certificate
.addSubjectDescription((CertificateSubjectDescription) subjectDescription[i]);
}
try {
certificate.encode();
} catch (DerEncodingException ex) {
throw new SecurityException("DerEncodingException: " + ex);
} catch (DerDecodingException ex_0) {
throw new SecurityException("DerDecodingException: " + ex_0);
}
return certificate;
}
示例6: checkSetDefaultKeyNameForIdentity
/// <summary>
/// Throw an exception if it is an error for setDefaultKeyNameForIdentity to
/// set it.
/// </summary>
///
/// <param name="keyName">The key name.</param>
/// <param name="identityNameCheck">The identity name to check the keyName.</param>
/// <exception cref="System.Security.SecurityException">if the identity name does not match the key nameor other problem.</exception>
protected internal void checkSetDefaultKeyNameForIdentity(Name keyName,
Name identityNameCheck)
{
Name identityName = keyName.getPrefix(-1);
if (identityNameCheck.size() > 0
&& !identityNameCheck.equals(identityName))
throw new SecurityException(
"The specified identity name does not match the key name");
}
示例7: matchesRelation
/// <summary>
/// Determines if a name satisfies the relation to another name, based on
/// matchRelation.
/// </summary>
///
/// <param name="name"></param>
/// <param name="matchName"></param>
/// <param name="matchRelation">name as a prefix "is-strict-prefix-of" - passes if the name has the other name as a prefix, and is not equal "equal" - passes if the two names are equal</param>
/// <returns>True if matches.</returns>
private static bool matchesRelation(Name name, Name matchName,
String matchRelation)
{
bool passed = false;
if (matchRelation.equals("is-strict-prefix-of")) {
if (matchName.size() == name.size())
passed = false;
else if (matchName.match(name))
passed = true;
} else if (matchRelation.equals("is-prefix-of")) {
if (matchName.match(name))
passed = true;
} else if (matchRelation.equals("equal")) {
if (matchName.equals(name))
passed = true;
}
return passed;
}