当前位置: 首页>>代码示例>>Java>>正文


Java X509CertSelector.setPathToNames方法代码示例

本文整理汇总了Java中java.security.cert.X509CertSelector.setPathToNames方法的典型用法代码示例。如果您正苦于以下问题:Java X509CertSelector.setPathToNames方法的具体用法?Java X509CertSelector.setPathToNames怎么用?Java X509CertSelector.setPathToNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.security.cert.X509CertSelector的用法示例。


在下文中一共展示了X509CertSelector.setPathToNames方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test_getPathToNames

import java.security.cert.X509CertSelector; //导入方法依赖的package包/类
/**
 * @tests java.security.cert.X509CertSelector#getPathToNames()
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "getPathToNames",
    args = {}
)
public void test_getPathToNames() {
    try {
        GeneralName san0 = new GeneralName(new OtherName("1.2.3.4.5",
                new byte[] { 1, 2, 0, 1 }));
        GeneralName san1 = new GeneralName(1, "[email protected]");
        GeneralName san2 = new GeneralName(2, "dNSName");
        GeneralName san3 = new GeneralName(new ORAddress());
        GeneralName san4 = new GeneralName(new Name("O=Organization"));
        GeneralName san6 = new GeneralName(6, "http://uniform.Resource.Id");
        GeneralName san7 = new GeneralName(7, "1.1.1.1");
        GeneralName san8 = new GeneralName(8, "1.2.3.4444.55555");

        GeneralNames sans1 = new GeneralNames();
        sans1.addName(san0);
        sans1.addName(san1);
        sans1.addName(san2);
        sans1.addName(san3);
        sans1.addName(san4);
        sans1.addName(san6);
        sans1.addName(san7);
        sans1.addName(san8);
        GeneralNames sans2 = new GeneralNames();
        sans2.addName(san0);

        TestCert cert1 = new TestCert(sans1);
        TestCert cert2 = new TestCert(sans2);
        X509CertSelector selector = new X509CertSelector();
        selector.setMatchAllSubjectAltNames(true);

        selector.setPathToNames(null);
        assertTrue("Any certificate should match in the case of null "
                + "subjectAlternativeNames criteria.", selector
                .match(cert1)
                && selector.match(cert2));

        Collection<List<?>> sans = sans1.getPairsList();

        selector.setPathToNames(sans);

        Collection<List<?>> col = selector.getPathToNames();
        Iterator<List<?>> i = col.iterator();
        while (i.hasNext()) {
            Object o = i.next();
            if (!(o instanceof List)) {
                fail("expected a List");
            }
        }

    } catch (IOException e) {
        e.printStackTrace();
        fail("Unexpected IOException was thrown.");
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:63,代码来源:X509CertSelectorTest.java

示例2: test_setPathToNamesLjava_util_Collection

import java.security.cert.X509CertSelector; //导入方法依赖的package包/类
/**
 * @tests java.security.cert.X509CertSelector#setPathToNames(Collection<List<?>>)
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "setPathToNames",
    args = {java.util.Collection.class}
)
public void test_setPathToNamesLjava_util_Collection() {
    try {
        GeneralName san0 = new GeneralName(new OtherName("1.2.3.4.5",
                new byte[] { 1, 2, 0, 1 }));
        GeneralName san1 = new GeneralName(1, "[email protected]");
        GeneralName san2 = new GeneralName(2, "dNSName");
        GeneralName san3 = new GeneralName(new ORAddress());
        GeneralName san4 = new GeneralName(new Name("O=Organization"));
        GeneralName san6 = new GeneralName(6, "http://uniform.Resource.Id");
        GeneralName san7 = new GeneralName(7, "1.1.1.1");
        GeneralName san8 = new GeneralName(8, "1.2.3.4444.55555");

        GeneralNames sans1 = new GeneralNames();
        sans1.addName(san0);
        sans1.addName(san1);
        sans1.addName(san2);
        sans1.addName(san3);
        sans1.addName(san4);
        sans1.addName(san6);
        sans1.addName(san7);
        sans1.addName(san8);
        GeneralNames sans2 = new GeneralNames();
        sans2.addName(san0);

        TestCert cert1 = new TestCert(sans1);
        TestCert cert2 = new TestCert(sans2);
        X509CertSelector selector = new X509CertSelector();
        selector.setMatchAllSubjectAltNames(true);

        selector.setPathToNames(null);
        assertTrue("Any certificate should match in the case of null "
                + "subjectAlternativeNames criteria.", selector
                .match(cert1)
                && selector.match(cert2));

        Collection<List<?>> sans = sans1.getPairsList();

        selector.setPathToNames(sans);

        Collection<List<?>> col = selector.getPathToNames();
        Iterator<List<?>> i = col.iterator();
        while (i.hasNext()) {
            Object o = i.next();
            if (!(o instanceof List)) {
                fail("expected a List");
            }
        }

    } catch (IOException e) {
        e.printStackTrace();
        fail("Unexpected IOException was thrown.");
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:63,代码来源:X509CertSelectorTest.java


注:本文中的java.security.cert.X509CertSelector.setPathToNames方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。