Inheritance: Org.BouncyCastle.Asn1.Asn1Encodable
		/**
         * @param attribute
         */
        public void AddAttribute(AttributeX509 attribute)
        {
            attributes.Add(attribute);
        }
		/**
		 * Produce an object suitable for an Asn1OutputStream.
		 *
		 * Returns:
		 *
		 * <pre>
		 *      SubjectDirectoryAttributes ::= Attributes
		 *      Attributes ::= SEQUENCE SIZE (1..MAX) OF Attribute
		 *      Attribute ::= SEQUENCE
		 *      {
		 *        type AttributeType
		 *        values SET OF AttributeValue
		 *      }
		 *
		 *      AttributeType ::= OBJECT IDENTIFIER
		 *      AttributeValue ::= ANY DEFINED BY AttributeType
		 * </pre>
		 *
		 * @return a DERObject
		 */
		public override Asn1Object ToAsn1Object()
		{
            AttributeX509[] v = new AttributeX509[attributes.Count];
            for (int i = 0; i < attributes.Count; ++i)
            {
                v[i] = (AttributeX509)attributes[i];
            }
            return new DerSequence(v);
		}
示例#3
0
		public void CheckAttributeCertificate(
			int		id,
			byte[]	cert)
		{
			Asn1Sequence seq = (Asn1Sequence) Asn1Object.FromByteArray(cert);
			string dump = Asn1Dump.DumpAsString(seq);

			AttributeCertificate obj = AttributeCertificate.GetInstance(seq);
			AttributeCertificateInfo acInfo = obj.ACInfo;

			// Version
			if (!(acInfo.Version.Equals(new DerInteger(1)))
				&& (!(acInfo.Version.Equals(new DerInteger(2)))))
			{
				Fail("failed AC Version test for id " + id);
			}

			// Holder
			Holder h = acInfo.Holder;
			if (h == null)
			{
				Fail("failed AC Holder test, it's null, for id " + id);
			}

			// Issuer
			AttCertIssuer aci = acInfo.Issuer;
			if (aci == null)
			{
				Fail("failed AC Issuer test, it's null, for id " + id);
			}

			// Signature
			AlgorithmIdentifier sig = acInfo.Signature;
			if (sig == null)
			{
				Fail("failed AC Signature test for id " + id);
			}

			// Serial
			DerInteger serial = acInfo.SerialNumber;

			// Validity
			AttCertValidityPeriod validity = acInfo.AttrCertValidityPeriod;
			if (validity == null)
			{
				Fail("failed AC AttCertValidityPeriod test for id " + id);
			}

			// Attributes
			Asn1Sequence attribSeq = acInfo.Attributes;
			AttributeX509[] att = new AttributeX509[attribSeq.Count];
			for (int i = 0; i < attribSeq.Count; i++)
			{
				att[i] = AttributeX509.GetInstance(attribSeq[i]);
			}

			// IssuerUniqueId
			// TODO, how to best test?

			// X509 Extensions
			X509Extensions ext = acInfo.Extensions;
			if (ext != null)
			{
				foreach (DerObjectIdentifier oid in ext.ExtensionOids)
				{
					X509Extension extVal = ext.GetExtension(oid);
				}
			}
		}
		/**
		 * Create an X.59 Attribute with the type given by the passed in oid and the
		 * value represented by an ASN.1 Set containing the objects in value.
		 *
		 * @param oid type of the attribute
		 * @param value vector of values to go in the attribute's value set.
		 */
		public X509Attribute(
			string              oid,
			Asn1EncodableVector value)
		{
			this.attr = new AttributeX509(new DerObjectIdentifier(oid), new DerSet(value));
		}
		/**
		 * @param at an object representing an attribute.
		 */
		internal X509Attribute(
			Asn1Encodable at)
		{
			this.attr = AttributeX509.GetInstance(at);
		}
 /**
  * @param attribute
  */
 public void AddAttribute(AttributeX509 attribute)
 {
     attributes.Add(attribute);
 }