Beispiel #1
0
        internal static bool ProcessCertD1i(
            int index,
            IList[]                         policyNodes,
            DerObjectIdentifier pOid,
            ISet pq)
        {
            IList policyNodeVec = policyNodes[index - 1];

            for (int j = 0; j < policyNodeVec.Count; j++)
            {
                PkixPolicyNode node             = (PkixPolicyNode)policyNodeVec[j];
                ISet           expectedPolicies = node.ExpectedPolicies;

                if (expectedPolicies.Contains(pOid.Id))
                {
                    ISet childExpectedPolicies = new HashSet();
                    childExpectedPolicies.Add(pOid.Id);

                    PkixPolicyNode child = new PkixPolicyNode(Platform.CreateArrayList(),
                                                              index,
                                                              childExpectedPolicies,
                                                              node,
                                                              pq,
                                                              pOid.Id,
                                                              false);
                    node.AddChild(child);
                    policyNodes[index].Add(child);

                    return(true);
                }
            }

            return(false);
        }
Beispiel #2
0
        internal static void ProcessCertD1ii(
            int index,
            IList[]                         policyNodes,
            DerObjectIdentifier _poid,
            ISet _pq)
        {
            IList policyNodeVec = policyNodes[index - 1];

            for (int j = 0; j < policyNodeVec.Count; j++)
            {
                PkixPolicyNode _node = (PkixPolicyNode)policyNodeVec[j];

                if (ANY_POLICY.Equals(_node.ValidPolicy))
                {
                    ISet _childExpectedPolicies = new HashSet();
                    _childExpectedPolicies.Add(_poid.Id);

                    PkixPolicyNode _child = new PkixPolicyNode(Platform.CreateArrayList(),
                                                               index,
                                                               _childExpectedPolicies,
                                                               _node,
                                                               _pq,
                                                               _poid.Id,
                                                               false);
                    _node.AddChild(_child);
                    policyNodes[index].Add(_child);
                    return;
                }
            }
        }
Beispiel #3
0
        public virtual PkixPolicyNode Copy()
        {
            PkixPolicyNode node = new PkixPolicyNode(
                Platform.CreateArrayList(),
                mDepth,
                new HashSet(mExpectedPolicies),
                null,
                new HashSet(mPolicyQualifiers),
                mValidPolicy,
                mCritical);

            foreach (PkixPolicyNode child in mChildren)
            {
                PkixPolicyNode copy = child.Copy();
                copy.Parent = node;
                node.AddChild(copy);
            }

            return(node);
        }
Beispiel #4
0
        internal static void PrepareNextCertB1(
            int i,
            IList[] policyNodes,
            string id_p,
            IDictionary m_idp,
            X509Certificate cert)
        {
            bool        idp_found = false;
            IEnumerator nodes_i   = policyNodes[i].GetEnumerator();

            while (nodes_i.MoveNext())
            {
                PkixPolicyNode node = (PkixPolicyNode)nodes_i.Current;
                if (node.ValidPolicy.Equals(id_p))
                {
                    idp_found             = true;
                    node.ExpectedPolicies = (ISet)m_idp[id_p];
                    break;
                }
            }

            if (!idp_found)
            {
                nodes_i = policyNodes[i].GetEnumerator();
                while (nodes_i.MoveNext())
                {
                    PkixPolicyNode node = (PkixPolicyNode)nodes_i.Current;
                    if (ANY_POLICY.Equals(node.ValidPolicy))
                    {
                        ISet         pq       = null;
                        Asn1Sequence policies = null;
                        try
                        {
                            policies = DerSequence.GetInstance(GetExtensionValue(cert, X509Extensions.CertificatePolicies));
                        }
                        catch (Exception e)
                        {
                            throw new Exception("Certificate policies cannot be decoded.", e);
                        }

                        IEnumerator enm = policies.GetEnumerator();
                        while (enm.MoveNext())
                        {
                            PolicyInformation pinfo = null;

                            try
                            {
                                pinfo = PolicyInformation.GetInstance(enm.Current);
                            }
                            catch (Exception ex)
                            {
                                throw new Exception("Policy information cannot be decoded.", ex);
                            }

                            if (ANY_POLICY.Equals(pinfo.PolicyIdentifier.Id))
                            {
                                try
                                {
                                    pq = GetQualifierSet(pinfo.PolicyQualifiers);
                                }
                                catch (PkixCertPathValidatorException ex)
                                {
                                    throw new PkixCertPathValidatorException(
                                              "Policy qualifier info set could not be built.", ex);
                                }
                                break;
                            }
                        }
                        bool ci          = false;
                        ISet critExtOids = cert.GetCriticalExtensionOids();
                        if (critExtOids != null)
                        {
                            ci = critExtOids.Contains(X509Extensions.CertificatePolicies.Id);
                        }

                        PkixPolicyNode p_node = (PkixPolicyNode)node.Parent;
                        if (ANY_POLICY.Equals(p_node.ValidPolicy))
                        {
                            PkixPolicyNode c_node = new PkixPolicyNode(
                                Platform.CreateArrayList(), i,
                                (ISet)m_idp[id_p],
                                p_node, pq, id_p, ci);
                            p_node.AddChild(c_node);
                            policyNodes[i].Add(c_node);
                        }
                        break;
                    }
                }
            }
        }