if (DEBUG) debug("adding policies to " + parent); for (Iterator it2 = cp.iterator(); it2.hasNext(); )
if (Configuration.DEBUG) log.fine("adding policies to " + parent); for (Iterator it2 = cp.iterator(); it2.hasNext();)
  private static void updatePolicyTree(X509Certificate cert, PolicyNodeImpl root,                                       int depth, PKIXParameters params,                                       boolean explicitPolicy)    throws CertPathValidatorException  {    if (DEBUG) debug("updatePolicyTree depth == " + depth);    Set nodes = new HashSet();    LinkedList stack = new LinkedList();    Iterator current = null;    stack.addLast(Collections.singleton(root).iterator());    do      {        current = (Iterator) stack.removeLast();        while (current.hasNext())          {            PolicyNodeImpl p = (PolicyNodeImpl) current.next();            if (DEBUG) debug("visiting node == " + p);            if (p.getDepth() == depth - 1)              {                if (DEBUG) debug("added node");                nodes.add(p);              }            else              {                if (DEBUG) debug("skipped node");                stack.addLast(current);                current = p.getChildren();              }          }      }    while (!stack.isEmpty());    Extension e = null;    CertificatePolicies policies = null;    List qualifierInfos = null;    if (cert instanceof GnuPKIExtension)      {        e = ((GnuPKIExtension) cert).getExtension(CertificatePolicies.ID);        if (e != null)          policies = (CertificatePolicies) e.getValue();      }    List cp = null;    if (policies != null)      cp = policies.getPolicies();    else      cp = Collections.EMPTY_LIST;    boolean match = false;    if (DEBUG) debug("nodes are == " + nodes);    if (DEBUG) debug("cert policies are == " + cp);    for (Iterator it = nodes.iterator(); it.hasNext(); )      {        PolicyNodeImpl parent = (PolicyNodeImpl) it.next();        if (DEBUG) debug("adding policies to " + parent);        for (Iterator it2 = cp.iterator(); it2.hasNext(); )          {            OID policy = (OID) it2.next();            if (DEBUG) debug("trying to add policy == " + policy);            if (policy.toString().equals(ANY_POLICY) &&                params.isAnyPolicyInhibited())              continue;            PolicyNodeImpl child = new PolicyNodeImpl();            child.setValidPolicy(policy.toString());            child.addExpectedPolicy(policy.toString());            if (parent.getExpectedPolicies().contains(policy.toString()))              {                parent.addChild(child);                match = true;              }            else if (parent.getExpectedPolicies().contains(ANY_POLICY))              {                parent.addChild(child);                match = true;              }            else if (ANY_POLICY.equals (policy.toString()))              {                parent.addChild (child);                match = true;              }            if (match && policies != null)              {                List qualifiers = policies.getPolicyQualifierInfos (policy);                if (qualifiers != null)                  child.addAllPolicyQualifiers (qualifiers);              }          }      }    if (!match && (params.isExplicitPolicyRequired() || explicitPolicy))      throw new CertPathValidatorException("policy tree building failed");  }