當前位置: 首頁>>代碼示例>>C#>>正文


C# X509Name.Equals方法代碼示例

本文整理匯總了C#中Org.BouncyCastle.Asn1.X509.X509Name.Equals方法的典型用法代碼示例。如果您正苦於以下問題:C# X509Name.Equals方法的具體用法?C# X509Name.Equals怎麽用?C# X509Name.Equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Org.BouncyCastle.Asn1.X509.X509Name的用法示例。


在下文中一共展示了X509Name.Equals方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetCertificateBySubjectName

 public IList<CertificateAndContext> GetCertificateBySubjectName(X509Name subjectName
     )
 {
     IList<CertificateAndContext> list = new AList<CertificateAndContext>();
     foreach (X509Certificate cert in GetCertificates())
     {
         if (subjectName.Equals(cert.SubjectDN))
         {
             CertificateAndContext cc = new CertificateAndContext(cert);
             cc.SetCertificateSource(sourceType);
             list.AddItem(cc);
         }
     }
     return list;
 }
開發者ID:Gianluigi,項目名稱:dssnet,代碼行數:15,代碼來源:OfflineCertificateSource.cs

示例2: PerformTest


//.........這裏部分代碼省略.........

			name1 = new X509Name(ord1, attrs);
			name2 = new X509Name(ord2, attrs);

			if (name1.Equivalent(name2))
			{
				Fail("Failed different name test");
			}

			ord2 = new ArrayList();

			ord2.Add(X509Name.ST);
			ord2.Add(X509Name.L);
			ord2.Add(X509Name.O);
			ord2.Add(X509Name.C);

			name1 = new X509Name(ord1, attrs);
			name2 = new X509Name(ord2, attrs);

			if (name1.Equivalent(name2))
			{
				Fail("Failed subset name test");
			}


			compositeTest();


			//
			// getValues test
			//
			ArrayList v1 = name1.GetValues(X509Name.O);

			if (v1.Count != 1 || !v1[0].Equals("The Legion of the Bouncy Castle"))
			{
				Fail("O test failed");
			}

			ArrayList v2 = name1.GetValues(X509Name.L);

			if (v2.Count != 1 || !v2[0].Equals("Melbourne"))
			{
				Fail("L test failed");
			}

			//
			// general subjects test
			//
			for (int i = 0; i != subjects.Length; i++)
			{
				X509Name name = new X509Name(subjects[i]);
				byte[] encodedName = name.GetEncoded();
				name = X509Name.GetInstance(Asn1Object.FromByteArray(encodedName));

				if (!name.ToString().Equals(subjects[i]))
				{
					Fail("Failed regeneration test " + i);
				}
			}

			//
			// sort test
			//
			X509Name unsorted = new X509Name("SERIALNUMBER=BBB + CN=AA");

			if (!FromBytes(unsorted.GetEncoded()).ToString().Equals("CN=AA+SERIALNUMBER=BBB"))
開發者ID:randombit,項目名稱:hacrypto,代碼行數:67,代碼來源:X509NameTest.cs


注:本文中的Org.BouncyCastle.Asn1.X509.X509Name.Equals方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。