Org.BouncyCastle.X509.Store.X509AttrCertStoreSelector.SetTargetNames C# (CSharp) Method

SetTargetNames() public method

public SetTargetNames ( IEnumerable names ) : void
names IEnumerable
return void
		public void SetTargetNames(
			IEnumerable names)
		{
			targetNames = ExtractGeneralNames(names);
		}

Usage Example

		public void TestSelector()
		{
			IX509AttributeCertificate aCert = CreateAttrCert();
			X509AttrCertStoreSelector sel = new X509AttrCertStoreSelector();
			sel.AttributeCert = aCert;
			bool match = sel.Match(aCert);
			if (!match)
			{
				Fail("Selector does not match attribute certificate.");
			}
			sel.AttributeCert = null;
			match = sel.Match(aCert);
			if (!match)
			{
				Fail("Selector does not match attribute certificate.");
			}
			sel.Holder = aCert.Holder;
			match = sel.Match(aCert);
			if (!match)
			{
				Fail("Selector does not match attribute certificate holder.");
			}
			sel.Holder = null;
			sel.Issuer = aCert.Issuer;
			match = sel.Match(aCert);
			if (!match)
			{
				Fail("Selector does not match attribute certificate issuer.");
			}
			sel.Issuer = null;

//			CertificateFactory fact = CertificateFactory.getInstance("X.509", "BC");
//			X509Certificate iCert = (X509Certificate) fact.generateCertificate(
//				new ByteArrayInputStream(holderCert));
			X509Certificate iCert = new X509CertificateParser().ReadCertificate(holderCert);
			match = aCert.Holder.Match(iCert);
			if (!match)
			{
				Fail("Issuer holder does not match signing certificate of attribute certificate.");
			}

			sel.SerialNumber = aCert.SerialNumber;
			match = sel.Match(aCert);
			if (!match)
			{
				Fail("Selector does not match attribute certificate serial number.");
			}

			sel.AttributeCertificateValid = new DateTimeObject(DateTime.UtcNow);
			match = sel.Match(aCert);
			if (!match)
			{
				Fail("Selector does not match attribute certificate time.");
			}

			sel.AddTargetName(new GeneralName(2, "www.test.com"));
			match = sel.Match(aCert);
			if (!match)
			{
				Fail("Selector does not match attribute certificate target name.");
			}
			sel.SetTargetNames(null);
			sel.AddTargetGroup(new GeneralName(4, "o=Test, ou=Test"));
			match = sel.Match(aCert);
			if (!match)
			{
				Fail("Selector does not match attribute certificate target group.");
			}
			sel.SetTargetGroups(null);
		}