for (int i = index - 1; i > 0; i--)
{
if (! path[i].getIssuerDN().equals(path[i].getSubjectDN()))
pathLen++;
}
Extension e = null;
if (cert instanceof GnuPKIExtension)
{
e = ((GnuPKIExtension) cert).getExtension(BasicConstraints.ID);
}
else
{
try
{
e = new Extension(cert.getExtensionValue(BasicConstraints.ID.toString()));
}
catch (Exception x)
{
}
}
if (e == null)
throw new CertPathValidatorException("no basicConstraints");
BasicConstraints bc = (BasicConstraints) e.getValue();
if (! bc.isCA())
throw new CertPathValidatorException(
"certificate cannot be used to verify signatures");
if (bc.getPathLengthConstraint() >= 0
&& bc.getPathLengthConstraint() < pathLen)