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

📄 pkixnameconstraintstest.java

📁 kmlnjlkj nlkjlkjkljl okopokipoipo oipipipo i
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     *            must not be excluded and included.     * @param testNames1 Operand 1 of test names to use for union and     *            intersection testing.     * @param testNames2 Operand 2 of test names to use for union and     *            intersection testing.     * @param testUnion The union results.     * @param testInterSection The intersection results.     * @throws Exception If an unexpected exception occurs.     */    private void testConstraints(        int nameType,        String testName,        String[] testNameIsConstraint,        String[] testNameIsNotConstraint,        String[] testNames1,        String[] testNames2,        String[][] testUnion,        String[] testInterSection) throws Exception    {        for (int i = 0; i < testNameIsConstraint.length; i++)        {            PKIXNameConstraintValidator constraintValidator = new PKIXNameConstraintValidator();            constraintValidator.intersectPermittedSubtree(new DERSequence(new GeneralSubtree(                new GeneralName(nameType, testNameIsConstraint[i]))));            constraintValidator.checkPermitted(new GeneralName(nameType, testName));        }        for (int i = 0; i < testNameIsNotConstraint.length; i++)        {            PKIXNameConstraintValidator constraintValidator = new PKIXNameConstraintValidator();            constraintValidator.intersectPermittedSubtree(new DERSequence(new GeneralSubtree(                new GeneralName(nameType, testNameIsNotConstraint[i]))));            try            {                constraintValidator.checkPermitted(new GeneralName(nameType, 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, testNameIsConstraint[i])));            try            {                constraintValidator.checkExcluded(new GeneralName(nameType, 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, testNameIsNotConstraint[i])));            constraintValidator.checkExcluded(new GeneralName(nameType, testName));        }        for (int i = 0; i < testNames1.length; i++)        {            PKIXNameConstraintValidator constraintValidator = new PKIXNameConstraintValidator();            constraintValidator.addExcludedSubtree(new GeneralSubtree(new GeneralName(                nameType, testNames1[i])));            constraintValidator.addExcludedSubtree(new GeneralSubtree(new GeneralName(                nameType, testNames2[i])));            PKIXNameConstraintValidator constraints2 = new PKIXNameConstraintValidator();            for (int j = 0; j < testUnion[i].length; j++)            {                constraints2.addExcludedSubtree(new GeneralSubtree(                    new GeneralName(nameType, testUnion[i][j])));            }            if (!constraints2.equals(constraintValidator))            {                fail("union wrong: " + nameType);            }            constraintValidator = new PKIXNameConstraintValidator();            constraintValidator.intersectPermittedSubtree(new DERSequence(new GeneralSubtree(                new GeneralName(nameType, testNames1[i]))));            constraintValidator.intersectPermittedSubtree(new DERSequence(new GeneralSubtree(                new GeneralName(nameType, testNames2[i]))));            constraints2 = new PKIXNameConstraintValidator();            if (testInterSection[i] != null)            {                constraints2.intersectPermittedSubtree(new DERSequence(new GeneralSubtree(                    new GeneralName(nameType, testInterSection[i]))));            }            else            {                constraints2.intersectEmptyPermittedSubtree(nameType);            }            if (!constraints2.equals(constraintValidator))            {                fail("intersection wrong: " + nameType);            }        }    }    /**     * Tests byte array based GeneralNames for inclusion or exclusion.     *      * @param nameType The {@link GeneralName} type to test.     * @param testName The name to test.     * @param testNameIsConstraint The names where <code>testName</code> must     *            be included and excluded.     * @param testNameIsNotConstraint The names where <code>testName</code>     *            must not be excluded and included.     * @param testNames1 Operand 1 of test names to use for union and     *            intersection testing.     * @param testNames2 Operand 2 of test names to use for union and     *            intersection testing.     * @param testUnion The union results.     * @param testInterSection The intersection results.     * @throws Exception If an unexpected exception occurs.     */    private void testConstraints(        int nameType,        byte[] testName,        byte[][] testNameIsConstraint,        byte[][] testNameIsNotConstraint,        byte[][] testNames1,        byte[][] testNames2,        byte[][][] testUnion,        byte[][] testInterSection) throws Exception    {        for (int i = 0; i < testNameIsConstraint.length; i++)        {            PKIXNameConstraintValidator constraintValidator = new PKIXNameConstraintValidator();            constraintValidator.intersectPermittedSubtree(new DERSequence(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 DERSequence(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 DERSequence(new GeneralSubtree(                new GeneralName(nameType, new DEROctetString(testNames1[i])))));            constraintValidator.intersectPermittedSubtree(new DERSequence(new GeneralSubtree(                new GeneralName(nameType, new DEROctetString(testNames2[i])))));            constraints2 = new PKIXNameConstraintValidator();            if (testInterSection[i] != null)            {                constraints2.intersectPermittedSubtree(new DERSequence(new GeneralSubtree(                new GeneralName(nameType, new DEROctetString(                    testInterSection[i])))));            }            else            {                constraints2.intersectEmptyPermittedSubtree(nameType);            }            if (!constraints2.equals(constraintValidator))            {                fail("intersection wrong: " + nameType);            }        }    }    public static void main(String[] args)    {        runTest(new PKIXNameConstraintsTest());    }}

⌨️ 快捷键说明

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