コード例 #1
0
        private IX509AttributeCertificate ReadPemCertificate(Stream inStream)
        {
            Asn1Sequence asn1Sequence = PemAttrCertParser.ReadPemObject(inStream);

            if (asn1Sequence != null)
            {
                return(new X509V2AttributeCertificate(AttributeCertificate.GetInstance(asn1Sequence)));
            }
            return(null);
        }
コード例 #2
0
        private IX509AttributeCertificate ReadPemCertificate(
            Stream inStream)
        {
            Asn1Sequence seq = PemAttrCertParser.ReadPemObject(inStream);

            return(seq == null
                                ?       null
                   //:	new X509V2AttributeCertificate(seq.getEncoded());
                                :       new X509V2AttributeCertificate(AttributeCertificate.GetInstance(seq)));
        }
コード例 #3
0
        private IX509AttributeCertificate ReadDerCertificate(Asn1InputStream dIn)
        {
            Asn1Sequence asn1Sequence = (Asn1Sequence)dIn.ReadObject();

            if (asn1Sequence.Count > 1 && asn1Sequence[0] is DerObjectIdentifier && asn1Sequence[0].Equals(PkcsObjectIdentifiers.SignedData))
            {
                this.sData = SignedData.GetInstance(Asn1Sequence.GetInstance((Asn1TaggedObject)asn1Sequence[1], true)).Certificates;
                return(this.GetCertificate());
            }
            return(new X509V2AttributeCertificate(AttributeCertificate.GetInstance(asn1Sequence)));
        }
コード例 #4
0
        public static CmpCertificate GetInstance(object obj)
        {
            if (obj is CmpCertificate)
                return (CmpCertificate)obj;

            if (obj is Asn1Sequence)
                return new CmpCertificate(X509CertificateStructure.GetInstance(obj));

            if (obj is Asn1TaggedObject)
                return new CmpCertificate(AttributeCertificate.GetInstance(((Asn1TaggedObject)obj).GetObject()));

            throw new ArgumentException("Invalid object: " + Platform.GetTypeName(obj), "obj");
        }
コード例 #5
0
 public void AddAttributeCertificates(IX509Store store)
 {
     try
     {
         foreach (IX509AttributeCertificate iX509AttributeCertificate in store.GetMatches(null))
         {
             this._certs.Add(new DerTaggedObject(false, 2, AttributeCertificate.GetInstance(Asn1Object.FromByteArray(iX509AttributeCertificate.GetEncoded()))));
         }
     }
     catch (Exception e)
     {
         throw new CmsException("error processing attribute certs", e);
     }
 }
コード例 #6
0
 private IX509AttributeCertificate GetCertificate()
 {
     if (this.sData != null)
     {
         while (this.sDataObjectCount < this.sData.Count)
         {
             object obj = this.sData[this.sDataObjectCount++];
             if (obj is Asn1TaggedObject && ((Asn1TaggedObject)obj).TagNo == 2)
             {
                 return(new X509V2AttributeCertificate(AttributeCertificate.GetInstance(Asn1Sequence.GetInstance((Asn1TaggedObject)obj, false))));
             }
         }
     }
     return(null);
 }
コード例 #7
0
 private static AttributeCertificate GetObject(Stream input)
 {
     try
     {
         return(AttributeCertificate.GetInstance(Asn1Object.FromStream(input)));
     }
     catch (IOException e)
     {
         throw e;
     }
     catch (Exception e)
     {
         throw new IOException("exception decoding certificate structure", e);
     }
 }
コード例 #8
0
 public static CmpCertificate GetInstance(object obj)
 {
     if (obj is CmpCertificate)
     {
         return((CmpCertificate)obj);
     }
     if (obj is Asn1Sequence)
     {
         return(new CmpCertificate(X509CertificateStructure.GetInstance(obj)));
     }
     if (obj is Asn1TaggedObject)
     {
         return(new CmpCertificate(AttributeCertificate.GetInstance(((Asn1TaggedObject)obj).GetObject())));
     }
     throw new ArgumentException("Invalid object: " + obj.GetType().Name, "obj");
 }
コード例 #9
0
 public static CmpCertificate GetInstance(object obj)
 {
     //IL_0056: Unknown result type (might be due to invalid IL or missing references)
     if (obj is CmpCertificate)
     {
         return((CmpCertificate)obj);
     }
     if (obj is Asn1Sequence)
     {
         return(new CmpCertificate(X509CertificateStructure.GetInstance(obj)));
     }
     if (obj is Asn1TaggedObject)
     {
         return(new CmpCertificate(AttributeCertificate.GetInstance(((Asn1TaggedObject)obj).GetObject())));
     }
     throw new ArgumentException("Invalid object: " + Platform.GetTypeName(obj), "obj");
 }
コード例 #10
0
        private SignerAttribute(object obj)
        {
            Asn1Sequence    asn1Sequence    = (Asn1Sequence)obj;
            DerTaggedObject derTaggedObject = (DerTaggedObject)asn1Sequence[0];

            if (derTaggedObject.TagNo == 0)
            {
                this.claimedAttributes = Asn1Sequence.GetInstance(derTaggedObject, true);
                return;
            }
            if (derTaggedObject.TagNo == 1)
            {
                this.certifiedAttributes = AttributeCertificate.GetInstance(derTaggedObject);
                return;
            }
            throw new ArgumentException("illegal tag.", "obj");
        }
コード例 #11
0
 private static AttributeCertificate GetObject(Stream input)
 {
     //IL_000f: Expected O, but got Unknown
     //IL_0018: Unknown result type (might be due to invalid IL or missing references)
     try
     {
         return(AttributeCertificate.GetInstance(Asn1Object.FromStream(input)));
     }
     catch (IOException val)
     {
         IOException val2 = val;
         throw val2;
     }
     catch (global::System.Exception ex)
     {
         throw new IOException("exception decoding certificate structure", ex);
     }
 }
コード例 #12
0
        private static AttributeCertificate GetObject(Stream input)
        {
            AttributeCertificate instance;

            try
            {
                instance = AttributeCertificate.GetInstance(Asn1Object.FromStream(input));
            }
            catch (IOException ex)
            {
                throw ex;
            }
            catch (Exception innerException)
            {
                throw new IOException("exception decoding certificate structure", innerException);
            }
            return(instance);
        }
コード例 #13
0
        private SignerAttribute(object obj)
        {
            //IL_0050: Unknown result type (might be due to invalid IL or missing references)
            Asn1Sequence    asn1Sequence    = (Asn1Sequence)obj;
            DerTaggedObject derTaggedObject = (DerTaggedObject)asn1Sequence[0];

            if (derTaggedObject.TagNo == 0)
            {
                claimedAttributes = Asn1Sequence.GetInstance(derTaggedObject, explicitly: true);
                return;
            }
            if (derTaggedObject.TagNo == 1)
            {
                certifiedAttributes = AttributeCertificate.GetInstance(derTaggedObject);
                return;
            }
            throw new ArgumentException("illegal tag.", "obj");
        }
コード例 #14
0
        private IX509AttributeCertificate ReadDerCertificate(
            Asn1InputStream dIn)
        {
            Asn1Sequence seq = (Asn1Sequence)dIn.ReadObject();

            if (seq.Count > 1 && seq[0] is DerObjectIdentifier)
            {
                if (seq[0].Equals(PkcsObjectIdentifiers.SignedData))
                {
                    sData = SignedData.GetInstance(
                        Asn1Sequence.GetInstance((Asn1TaggedObject)seq[1], true)).Certificates;

                    return(GetCertificate());
                }
            }

//			return new X509V2AttributeCertificate(seq.getEncoded());
            return(new X509V2AttributeCertificate(AttributeCertificate.GetInstance(seq)));
        }
コード例 #15
0
        private SignerAttribute(
            object obj)
        {
            Asn1Sequence    seq          = (Asn1Sequence)obj;
            DerTaggedObject taggedObject = (DerTaggedObject)seq[0];

            if (taggedObject.TagNo == 0)
            {
                claimedAttributes = Asn1Sequence.GetInstance(taggedObject, true);
            }
            else if (taggedObject.TagNo == 1)
            {
                certifiedAttributes = AttributeCertificate.GetInstance(taggedObject);
            }
            else
            {
                throw new ArgumentException("illegal tag.", "obj");
            }
        }
コード例 #16
0
        public static CmpCertificate GetInstance(object obj)
        {
            if (obj is CmpCertificate)
            {
                return((CmpCertificate)obj);
            }

            if (obj is Asn1Sequence)
            {
                return(new CmpCertificate(X509CertificateStructure.GetInstance(obj)));
            }

            if (obj is Asn1TaggedObject)
            {
                return(new CmpCertificate(AttributeCertificate.GetInstance(((Asn1TaggedObject)obj).GetObject())));
            }

            throw new ArgumentException("Invalid object: " + BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
        }
コード例 #17
0
        private IX509AttributeCertificate GetCertificate()
        {
            if (sData != null)
            {
                while (sDataObjectCount < sData.Count)
                {
                    object obj = sData[sDataObjectCount++];

                    if (obj is Asn1TaggedObject && ((Asn1TaggedObject)obj).TagNo == 2)
                    {
                        //return new X509V2AttributeCertificate(
                        //	Asn1Sequence.GetInstance((Asn1TaggedObject)obj, false).GetEncoded());
                        return(new X509V2AttributeCertificate(
                                   AttributeCertificate.GetInstance(
                                       Asn1Sequence.GetInstance((Asn1TaggedObject)obj, false))));
                    }
                }
            }

            return(null);
        }
コード例 #18
0
 internal X509V2AttributeCertificate(
     Asn1InputStream ais)
     : this(AttributeCertificate.GetInstance(ais.ReadObject()))
 {
 }
コード例 #19
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);
                }
            }
        }