{
for (int i = 0; i < testNameIsConstraint.length; i++)
{
PKIXNameConstraintValidator constraintValidator = new PKIXNameConstraintValidator();
constraintValidator.intersectPermittedSubtree(new GeneralSubtree(
new GeneralName(nameType, new DEROctetString(
testNameIsConstraint[i]))));
constraintValidator.checkPermitted(new GeneralName(nameType,
new DEROctetString(testName)));
}
for (int i = 0; i < testNameIsNotConstraint.length; i++)
{
PKIXNameConstraintValidator constraintValidator = new PKIXNameConstraintValidator();
constraintValidator.intersectPermittedSubtree(new GeneralSubtree(
new GeneralName(nameType, new DEROctetString(
testNameIsNotConstraint[i]))));
try
{
constraintValidator.checkPermitted(new GeneralName(nameType,
new DEROctetString(testName)));
fail("not permitted name allowed: " + nameType);
}
catch (PKIXNameConstraintValidatorException e)
{
// expected
}
}
for (int i = 0; i < testNameIsConstraint.length; i++)
{
PKIXNameConstraintValidator constraintValidator = new PKIXNameConstraintValidator();
constraintValidator.addExcludedSubtree(new GeneralSubtree(new GeneralName(
nameType, new DEROctetString(testNameIsConstraint[i]))));
try
{
constraintValidator.checkExcluded(new GeneralName(nameType,
new DEROctetString(testName)));
fail("excluded name missed: " + nameType);
}
catch (PKIXNameConstraintValidatorException e)
{
// expected
}
}
for (int i = 0; i < testNameIsNotConstraint.length; i++)
{
PKIXNameConstraintValidator constraintValidator = new PKIXNameConstraintValidator();
constraintValidator.addExcludedSubtree(new GeneralSubtree(new GeneralName(
nameType, new DEROctetString(testNameIsNotConstraint[i]))));
constraintValidator.checkExcluded(new GeneralName(nameType,
new DEROctetString(testName)));
}
for (int i = 0; i < testNames1.length; i++)
{
PKIXNameConstraintValidator constraintValidator = new PKIXNameConstraintValidator();
constraintValidator.addExcludedSubtree(new GeneralSubtree(new GeneralName(
nameType, new DEROctetString(testNames1[i]))));
constraintValidator.addExcludedSubtree(new GeneralSubtree(new GeneralName(
nameType, new DEROctetString(testNames2[i]))));
PKIXNameConstraintValidator constraints2 = new PKIXNameConstraintValidator();
for (int j = 0; j < testUnion[i].length; j++)
{
constraints2.addExcludedSubtree(new GeneralSubtree(
new GeneralName(nameType, new DEROctetString(
testUnion[i][j]))));
}
if (!constraints2.equals(constraintValidator))
{
fail("union wrong: " + nameType);
}
constraintValidator = new PKIXNameConstraintValidator();
constraintValidator.intersectPermittedSubtree(new GeneralSubtree(
new GeneralName(nameType, new DEROctetString(testNames1[i]))));
constraintValidator.intersectPermittedSubtree(new GeneralSubtree(
new GeneralName(nameType, new DEROctetString(testNames2[i]))));
constraints2 = new PKIXNameConstraintValidator();
if (testInterSection[i] != null)
{
constraints2.intersectPermittedSubtree(new GeneralSubtree(
new GeneralName(nameType, new DEROctetString(
testInterSection[i]))));
}
else
{
constraints2.intersectEmptyPermittedSubtree(nameType);