コード例 #1
0
        public AttributeCertificateInfo(
            ASN1Sequence seq)
        {
            this.version                = DERInteger.getInstance(seq.getObjectAt(0));
            this.holder                 = Holder.getInstance(seq.getObjectAt(1));
            this.issuer                 = AttCertIssuer.getInstance(seq.getObjectAt(2));
            this.signature              = AlgorithmIdentifier.getInstance(seq.getObjectAt(3));
            this.serialNumber           = DERInteger.getInstance(seq.getObjectAt(4));
            this.attrCertValidityPeriod = AttCertValidityPeriod.getInstance(seq.getObjectAt(5));
            this.attributes             = ASN1Sequence.getInstance(seq.getObjectAt(6));

            for (int i = 7; i < seq.size(); i++)
            {
                ASN1Encodable obj = (ASN1Encodable)seq.getObjectAt(i);

                if (obj is DERBitString)
                {
                    this.issuerUniqueID = DERBitString.getInstance(seq.getObjectAt(i));
                }
                else if (obj is ASN1Sequence || obj is X509Extensions)
                {
                    this.extensions = X509Extensions.getInstance(seq.getObjectAt(i));
                }
            }
        }
コード例 #2
0
 private AttributeCertificateInfo(Asn1Sequence seq)
 {
     if (seq.Count < 7 || seq.Count > 9)
     {
         throw new ArgumentException("Bad sequence size: " + seq.Count);
     }
     version                = DerInteger.GetInstance(seq[0]);
     holder                 = Holder.GetInstance(seq[1]);
     issuer                 = AttCertIssuer.GetInstance(seq[2]);
     signature              = AlgorithmIdentifier.GetInstance(seq[3]);
     serialNumber           = DerInteger.GetInstance(seq[4]);
     attrCertValidityPeriod = AttCertValidityPeriod.GetInstance(seq[5]);
     attributes             = Asn1Sequence.GetInstance(seq[6]);
     for (int i = 7; i < seq.Count; i++)
     {
         Asn1Encodable asn1Encodable = seq[i];
         if (asn1Encodable is DerBitString)
         {
             issuerUniqueID = DerBitString.GetInstance(seq[i]);
         }
         else if (asn1Encodable is Asn1Sequence || asn1Encodable is X509Extensions)
         {
             extensions = X509Extensions.GetInstance(seq[i]);
         }
     }
 }
 /// <summary>Set the issuer.</summary>
 public void SetIssuer(
     AttributeCertificateIssuer issuer)
 {
     acInfoGen.SetIssuer(AttCertIssuer.GetInstance(issuer.form));
 }
コード例 #4
0
 internal AttributeCertificateIssuer(
     AttCertIssuer issuer)
 {
     form = issuer.Issuer;
 }
コード例 #5
0
 public object Clone()
 {
     return(new AttributeCertificateIssuer(AttCertIssuer.GetInstance(form)));
 }
コード例 #6
0
 /**
  * Set the issuer directly with the ASN.1 structure.
  *
  * @param issuer The issuer
  */
 public AttributeCertificateIssuer(
     AttCertIssuer issuer)
 {
     form = issuer.Issuer;
 }
コード例 #7
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);
                }
            }
        }
 public void SetIssuer(AttCertIssuer issuer)
 {
     this.issuer = issuer;
 }