Пример #1
0
    public virtual PkixPolicyNode Copy()
    {
        PkixPolicyNode pkixPolicyNode = new PkixPolicyNode(Platform.CreateArrayList(), mDepth, new HashSet(mExpectedPolicies), null, new HashSet(mPolicyQualifiers), mValidPolicy, mCritical);

        foreach (PkixPolicyNode mChild in mChildren)
        {
            PkixPolicyNode pkixPolicyNode3 = mChild.Copy();
            pkixPolicyNode3.Parent = pkixPolicyNode;
            pkixPolicyNode.AddChild(pkixPolicyNode3);
        }
        return(pkixPolicyNode);
    }
    internal static bool ProcessCertD1i(int index, IList[] policyNodes, DerObjectIdentifier pOid, ISet pq)
    {
        IList list = policyNodes[index - 1];

        for (int i = 0; i < list.Count; i++)
        {
            PkixPolicyNode pkixPolicyNode   = (PkixPolicyNode)list[i];
            ISet           expectedPolicies = pkixPolicyNode.ExpectedPolicies;
            if (expectedPolicies.Contains(pOid.Id))
            {
                ISet set = new HashSet();
                set.Add(pOid.Id);
                PkixPolicyNode pkixPolicyNode2 = new PkixPolicyNode(Platform.CreateArrayList(), index, set, pkixPolicyNode, pq, pOid.Id, critical: false);
                pkixPolicyNode.AddChild(pkixPolicyNode2);
                policyNodes[index].Add(pkixPolicyNode2);
                return(true);
            }
        }
        return(false);
    }
    internal static void PrepareNextCertB1(int i, IList[] policyNodes, string id_p, IDictionary m_idp, X509Certificate cert)
    {
        bool        flag       = false;
        IEnumerator enumerator = policyNodes[i].GetEnumerator();

        while (enumerator.MoveNext())
        {
            PkixPolicyNode pkixPolicyNode = (PkixPolicyNode)enumerator.Current;
            if (pkixPolicyNode.ValidPolicy.Equals(id_p))
            {
                flag = true;
                pkixPolicyNode.ExpectedPolicies = (ISet)m_idp[id_p];
                break;
            }
        }
        if (flag)
        {
            return;
        }
        enumerator = policyNodes[i].GetEnumerator();
        PkixPolicyNode pkixPolicyNode2;

        do
        {
            if (enumerator.MoveNext())
            {
                pkixPolicyNode2 = (PkixPolicyNode)enumerator.Current;
                continue;
            }
            return;
        }while (!ANY_POLICY.Equals(pkixPolicyNode2.ValidPolicy));
        ISet         policyQualifiers = null;
        Asn1Sequence asn1Sequence     = null;

        try
        {
            asn1Sequence = Asn1Sequence.GetInstance(GetExtensionValue(cert, X509Extensions.CertificatePolicies));
        }
        catch (Exception innerException)
        {
            throw new Exception("Certificate policies cannot be decoded.", innerException);
        }
        IEnumerator enumerator2 = asn1Sequence.GetEnumerator();

        while (enumerator2.MoveNext())
        {
            PolicyInformation policyInformation = null;
            try
            {
                policyInformation = PolicyInformation.GetInstance(enumerator2.Current);
            }
            catch (Exception innerException2)
            {
                throw new Exception("Policy information cannot be decoded.", innerException2);
            }
            if (ANY_POLICY.Equals(policyInformation.PolicyIdentifier.Id))
            {
                try
                {
                    policyQualifiers = GetQualifierSet(policyInformation.PolicyQualifiers);
                }
                catch (PkixCertPathValidatorException cause)
                {
                    throw new PkixCertPathValidatorException("Policy qualifier info set could not be built.", cause);
                }
                break;
            }
        }
        bool critical = false;
        ISet criticalExtensionOids = cert.GetCriticalExtensionOids();

        if (criticalExtensionOids != null)
        {
            critical = criticalExtensionOids.Contains(X509Extensions.CertificatePolicies.Id);
        }
        PkixPolicyNode parent = pkixPolicyNode2.Parent;

        if (ANY_POLICY.Equals(parent.ValidPolicy))
        {
            PkixPolicyNode pkixPolicyNode3 = new PkixPolicyNode(Platform.CreateArrayList(), i, (ISet)m_idp[id_p], parent, policyQualifiers, id_p, critical);
            parent.AddChild(pkixPolicyNode3);
            policyNodes[i].Add(pkixPolicyNode3);
        }
    }