⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 certpathvalidatorutilities.java

📁 kmlnjlkj nlkjlkjkljl okopokipoipo oipipipo i
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
     *            to select the CRLs     * @param crlStores a List containing only     *            {@link org.bouncycastle.x509.X509Store  X509Store} objects.     *            These are used to search for CRLs     *     * @return a Collection of all found {@link X509CRL X509CRL} objects. May be     *         empty but never <code>null</code>.     */    protected static final Collection findCRLs(X509CRLStoreSelector crlSelect,        List crlStores) throws AnnotatedException    {        Set crls = new HashSet();        Iterator iter = crlStores.iterator();        AnnotatedException lastException = null;        boolean foundValidStore = false;        while (iter.hasNext())        {            Object obj = iter.next();            if (obj instanceof X509Store)            {                X509Store store = (X509Store)obj;                try                {                    crls.addAll(store.getMatches(crlSelect));                    foundValidStore = true;                }                catch (StoreException e)                {                    lastException = new AnnotatedException(                        "Exception searching in X.509 CRL store.", e);                }            }            else            {                CertStore store = (CertStore)obj;                try                {                    crls.addAll(store.getCRLs(crlSelect));                    foundValidStore = true;                }                catch (CertStoreException e)                {                    lastException = new AnnotatedException(                        "Exception searching in X.509 CRL store.", e);                }            }        }        if (!foundValidStore && lastException != null)        {            throw lastException;        }        return crls;    }    //    // policy checking    //         protected static final Set getQualifierSet(ASN1Sequence qualifiers)         throws CertPathValidatorException    {        Set             pq   = new HashSet();                if (qualifiers == null)        {            return pq;        }                ByteArrayOutputStream   bOut = new ByteArrayOutputStream();        ASN1OutputStream        aOut = new ASN1OutputStream(bOut);            Enumeration e = qualifiers.getObjects();            while (e.hasMoreElements())        {            try            {                aOut.writeObject(e.nextElement());                    pq.add(new PolicyQualifierInfo(bOut.toByteArray()));            }            catch (IOException ex)            {                throw new ExtCertPathValidatorException("Policy qualifier info cannot be decoded.", ex);            }                bOut.reset();        }                return pq;    }        protected static PKIXPolicyNode removePolicyNode(        PKIXPolicyNode  validPolicyTree,        List     []        policyNodes,        PKIXPolicyNode _node)    {        PKIXPolicyNode _parent = (PKIXPolicyNode)_node.getParent();                if (validPolicyTree == null)        {            return null;        }        if (_parent == null)        {            for (int j = 0; j < policyNodes.length; j++)            {                policyNodes[j] = new ArrayList();            }            return null;        }        else        {            _parent.removeChild(_node);            removePolicyNodeRecurse(policyNodes, _node);            return validPolicyTree;        }    }        private static void removePolicyNodeRecurse(        List     []        policyNodes,        PKIXPolicyNode  _node)    {        policyNodes[_node.getDepth()].remove(_node);        if (_node.hasChildren())        {            Iterator _iter = _node.getChildren();            while (_iter.hasNext())            {                PKIXPolicyNode _child = (PKIXPolicyNode)_iter.next();                removePolicyNodeRecurse(policyNodes, _child);            }        }    }            protected static boolean processCertD1i(        int                 index,        List     []            policyNodes,        DERObjectIdentifier pOid,        Set                 pq)    {        List       policyNodeVec = policyNodes[index - 1];        for (int j = 0; j < policyNodeVec.size(); j++)        {            PKIXPolicyNode node = (PKIXPolicyNode)policyNodeVec.get(j);            Set            expectedPolicies = node.getExpectedPolicies();                        if (expectedPolicies.contains(pOid.getId()))            {                Set childExpectedPolicies = new HashSet();                childExpectedPolicies.add(pOid.getId());                                PKIXPolicyNode child = new PKIXPolicyNode(new ArrayList(),                                                           index,                                                           childExpectedPolicies,                                                           node,                                                           pq,                                                           pOid.getId(),                                                           false);                node.addChild(child);                policyNodes[index].add(child);                                return true;            }        }                return false;    }    protected static void processCertD1ii(        int                 index,        List     []            policyNodes,        DERObjectIdentifier _poid,        Set _pq)    {        List       policyNodeVec = policyNodes[index - 1];        for (int j = 0; j < policyNodeVec.size(); j++)        {            PKIXPolicyNode _node = (PKIXPolicyNode)policyNodeVec.get(j);            if (ANY_POLICY.equals(_node.getValidPolicy()))            {                Set _childExpectedPolicies = new HashSet();                _childExpectedPolicies.add(_poid.getId());                                PKIXPolicyNode _child = new PKIXPolicyNode(new ArrayList(),                                                           index,                                                           _childExpectedPolicies,                                                           _node,                                                           _pq,                                                           _poid.getId(),                                                           false);                _node.addChild(_child);                policyNodes[index].add(_child);                return;            }        }    }        protected static void prepareNextCertB1(            int i,            List[] policyNodes,            String id_p,            Map m_idp,            X509Certificate cert            ) throws AnnotatedException,CertPathValidatorException    {        boolean idp_found = false;        Iterator nodes_i = policyNodes[i].iterator();        while (nodes_i.hasNext())        {            PKIXPolicyNode node = (PKIXPolicyNode)nodes_i.next();            if (node.getValidPolicy().equals(id_p))            {                idp_found = true;                node.expectedPolicies = (Set)m_idp.get(id_p);                break;            }        }        if (!idp_found)        {            nodes_i = policyNodes[i].iterator();            while (nodes_i.hasNext())            {                PKIXPolicyNode node = (PKIXPolicyNode)nodes_i.next();                if (ANY_POLICY.equals(node.getValidPolicy()))                {                    Set pq = null;                    ASN1Sequence policies = null;                    try                    {                        policies = DERSequence.getInstance(getExtensionValue(cert, CERTIFICATE_POLICIES));                    }                    catch (Exception e)                    {                        throw                        new AnnotatedException("Certificate policies cannot be decoded.", e);                    }                    Enumeration e = policies.getObjects();                    while (e.hasMoreElements())                    {                        PolicyInformation pinfo = null;                        try                        {                            pinfo = PolicyInformation.getInstance(e.nextElement());                        }                        catch (Exception ex)                        {                            throw new AnnotatedException("Policy information cannot be decoded.", ex);                        }                        if (ANY_POLICY.equals(pinfo.getPolicyIdentifier().getId()))                        {                            try                            {                            pq = getQualifierSet(pinfo.getPolicyQualifiers());                            }                            catch (CertPathValidatorException ex)                            {                                throw new ExtCertPathValidatorException(                                        "Policy qualifier info set could not be built.", ex);                            }                            break;                        }                    }                    boolean ci = false;                    if (cert.getCriticalExtensionOIDs() != null)                    {                        ci = cert.getCriticalExtensionOIDs().contains(CERTIFICATE_POLICIES);                    }                    PKIXPolicyNode p_node = (PKIXPolicyNode)node.getParent();                    if (ANY_POLICY.equals(p_node.getValidPolicy()))                    {                        PKIXPolicyNode c_node = new PKIXPolicyNode(                                new ArrayList(), i,                                (Set)m_idp.get(id_p),                                p_node, pq, id_p, ci);                        p_node.addChild(c_node);                        policyNodes[i].add(c_node);                    }                    break;                }            }        }    }        protected static PKIXPolicyNode prepareNextCertB2(            int i,            List[] policyNodes,            String id_p,            PKIXPolicyNode validPolicyTree)     {        Iterator nodes_i = policyNodes[i].iterator();        while (nodes_i.hasNext())        {            PKIXPolicyNode node = (PKIXPolicyNode)nodes_i.next();            if (node.getValidPolicy().equals(id_p))            {                PKIXPolicyNode p_node = (PKIXPolicyNode)node.getParent();                p_node.removeChild(node);                nodes_i.remove();                for (int k = (i - 1); k >= 0; k--)                {                    List nodes = policyNodes[k];                    for (int l = 0; l < nodes.size(); l++)                    {                        PKIXPolicyNode node2 = (PKIXPolicyNode)nodes.get(l);                        if (!node2.hasChildren())                        {                            validPolicyTree = removePolicyNode(validPolicyTree, policyNodes, node2);                            if (validPolicyTree == null)                            {                                break;                            }                        }                    }                }            }        }        return validPolicyTree;    }        protected static boolean isAnyPolicy(        Set policySet)    {        return policySet == null || policySet.contains(ANY_POLICY) || policySet.isEmpty();    }        protected static void addAdditionalStoreFromLocation(String location,        ExtendedPKIXParameters pkixParams)    {        if (pkixParams.isAdditionalLocationsEnabled())        {            try            {                if (location.startsWith("ldap://"))                {                    // ldap://directory.d-trust.net/CN=D-TRUST                    // Qualified CA 2003 1:PN,O=D-Trust GmbH,C=DE                    // skip "ldap://"                    location = location.substring(7);                    // after first / baseDN starts                    String base = null;                    String url = null;                    if (location.indexOf("/") != -1)                    {                        base = location.substring(location.indexOf("/"));                        // URL                        url = "ldap://"                            + location.substring(0, location.indexOf("/"));                    }                    else                    {                        url = "ldap://" + location;                    }                    // use all purpose parameters                    X509LDAPCertStoreParameters params = new X509LDAPCertStoreParameters.Builder(                        url, base).build();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -