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


Java ORAddress类代码示例

本文整理汇总了Java中org.apache.harmony.security.x509.ORAddress的典型用法代码示例。如果您正苦于以下问题:Java ORAddress类的具体用法?Java ORAddress怎么用?Java ORAddress使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ORAddress类属于org.apache.harmony.security.x509包,在下文中一共展示了ORAddress类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testORAddress

import org.apache.harmony.security.x509.ORAddress; //导入依赖的package包/类
/**
 * ORAddress() method testing.
 */
public void testORAddress() {
    ORAddress ora = new ORAddress();
    System.out.println("");
    System.out.println("ORAddress:");
    printAsHex(8, "", " ", ora.getEncoded());
    System.out.println("");
    
    GeneralName gName = new GeneralName(ora);
    System.out.println("GeneralName:");
    printAsHex(8, "", " ", gName.getEncoded());
    System.out.println("");

    GeneralNames gNames = new GeneralNames();
    gNames.addName(gName);
    System.out.println("GeneralNames:");
    printAsHex(8, "", " ", gNames.getEncoded());
    System.out.println("");
}
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:ORAddressTest.java

示例2: testORAddress

import org.apache.harmony.security.x509.ORAddress; //导入依赖的package包/类
/**
 * ORAddress() method testing.
 */
public void testORAddress() {
    try {
        ORAddress ora = new ORAddress();
        System.out.println("");
        System.out.println("ORAddress:");
        printAsHex(8, "", " ", ora.getEncoded());
        System.out.println("");
        
        GeneralName gName = new GeneralName(ora);
        System.out.println("GeneralName:");
        printAsHex(8, "", " ", gName.getEncoded());
        System.out.println("");

        GeneralNames gNames = new GeneralNames();
        gNames.addName(gName);
        System.out.println("GeneralNames:");
        printAsHex(8, "", " ", gNames.getEncoded());
        System.out.println("");

    } catch (Exception e) {
        e.printStackTrace();
        fail("Exception was thrown.");
    }
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:28,代码来源:ORAddressTest.java

示例3: testGeneralName

import org.apache.harmony.security.x509.ORAddress; //导入依赖的package包/类
public void testGeneralName() {
    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 san5 =
            new GeneralName(new EDIPartyName("assigner", "party"));
        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 sans_1 = new GeneralNames();
        sans_1.addName(san0);
        sans_1.addName(san1);
        sans_1.addName(san2);
        sans_1.addName(san3);
        sans_1.addName(san4);
        sans_1.addName(san5);
        sans_1.addName(san6);
        sans_1.addName(san7);
        sans_1.addName(san8);

        byte[] encoding =  GeneralNames.ASN1.encode(sans_1);
        GeneralNames.ASN1.decode(encoding);
    } catch (Exception e) {
        // should not be thrown:
        // provided string representations are correct
        e.printStackTrace();
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:34,代码来源:GeneralNameTest.java

示例4: test_getPathToNames

import org.apache.harmony.security.x509.ORAddress; //导入依赖的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

示例5: test_setPathToNamesLjava_util_Collection

import org.apache.harmony.security.x509.ORAddress; //导入依赖的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

示例6: test_setSubjectAlternativeNamesLjava_util_Collection

import org.apache.harmony.security.x509.ORAddress; //导入依赖的package包/类
/**
 * @tests java.security.cert.X509CertSelector#setSubjectAlternativeNames(Collection<List<?>>)
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "setSubjectAlternativeNames",
    args = {java.util.Collection.class}
)
public void test_setSubjectAlternativeNamesLjava_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.setSubjectAlternativeNames(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.setSubjectAlternativeNames(sans);

        Collection<List<?>> col = selector.getSubjectAlternativeNames();
        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,代码行数:64,代码来源:X509CertSelectorTest.java

示例7: testCertificate

import org.apache.harmony.security.x509.ORAddress; //导入依赖的package包/类
/**
 * Certificate(TBSCertificate tbsCertificate, AlgorithmIdentifier
 * signatureAlgorithm, byte[] signatureValue) method testing.
 * Makes the certificate, gets its encoded form, makes new certificate
 * from this encoded form by CertificateFactory, and decodes encoded
 * form.
 */
public void testCertificate() throws Exception {
    // make the TBSCertificate for Certificate
    int version = 2; //v3
    BigInteger serialNumber = BigInteger.valueOf(555L); 
    AlgorithmIdentifier signature = new AlgorithmIdentifier("1.2.3.44.555"); // random value
    Name issuer = new Name("O=Certificate Issuer");
    Validity validity = new Validity(new Date(100000000), new Date(200000000));
    Name subject = new Name("O=Subject Organization"); 
    SubjectPublicKeyInfo subjectPublicKeyInfo = 
        new SubjectPublicKeyInfo(new AlgorithmIdentifier("1.2.840.113549.1.1.2"), 
                new byte[10]);
    boolean[]   issuerUniqueID  = new boolean[] 
                {true, false, true, false, true, false, true, false}; // random value
    boolean[]   subjectUniqueID = new boolean[]
                {false, true, false, true, false, true, false, true}; // random value
    // make the Extensions for TBSCertificate
    // Subject Alternative Names
    GeneralName[] san = new GeneralName[] {
        new GeneralName(
            new OtherName("1.2.3.4.5",
                    ASN1Integer.getInstance().encode(
                            BigInteger.valueOf(55L).toByteArray()))),
        new GeneralName(1, "[email protected]"),
        new GeneralName(2, "dNSName"),
        new GeneralName(new ORAddress()),
        new GeneralName(4, "O=Organization"),
        new GeneralName(new EDIPartyName("assigner","party")),
        new GeneralName(6, "http://Resource.Id"),
        new GeneralName(new byte[] {1, 1, 1, 1}),
        new GeneralName(8, "1.2.3.4444.55555")
    };
    GeneralNames sans = new GeneralNames(Arrays.asList(san));
    Extension extension = new Extension("2.5.29.17", true, sans.getEncoded());
    Extensions extensions = new Extensions();
    extensions.addExtension(extension);
    
    byte[] encoding = extensions.getEncoded();
    Extensions.ASN1.decode(encoding);
    
    TBSCertificate tbsCertificate = new TBSCertificate(version, serialNumber, 
            signature, issuer, validity, subject, subjectPublicKeyInfo, 
            issuerUniqueID, subjectUniqueID, extensions);

    encoding = tbsCertificate.getEncoded();
    TBSCertificate.ASN1.decode(encoding);

    Certificate certificate = new Certificate(tbsCertificate, signature, new byte[10]);

    encoding = certificate.getEncoded();
    
    Certificate.ASN1.decode(encoding);

    encoding = Certificate.ASN1.encode(certificate);
    
    ByteArrayInputStream bais = new ByteArrayInputStream(encoding);

    //try {
        CertificateFactory cf = CertificateFactory.getInstance("X.509");
        cf.generateCertificate(bais);
    //} catch (CertificateException e) {
        // there is no X.509 certificate factory implementation installed
    //}
}
 
开发者ID:shannah,项目名称:cn1,代码行数:71,代码来源:CertificateTest.java

示例8: testSetSubjectAlternativeNames

import org.apache.harmony.security.x509.ORAddress; //导入依赖的package包/类
/**
 * setSubjectAlternativeNames(Collection<List<?>> names) method testing.
 */
public void testSetSubjectAlternativeNames() {
    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 san5 = 
            new GeneralName(new EDIPartyName("assigner", "party"));
        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 sans_1 = new GeneralNames();
        sans_1.addName(san0);
        sans_1.addName(san1);
        sans_1.addName(san2);
        sans_1.addName(san3);
        sans_1.addName(san4);
        sans_1.addName(san5);
        sans_1.addName(san6);
        sans_1.addName(san7);
        sans_1.addName(san8);
        GeneralNames sans_2 = new GeneralNames();
        sans_2.addName(san0);
        
        TestCert cert_1 = new TestCert(sans_1);
        TestCert cert_2 = new TestCert(sans_2);
        X509CertSelector selector = new X509CertSelector();
        selector.setMatchAllSubjectAltNames(true);

        selector.setSubjectAlternativeNames(null);
        assertTrue("Any certificate should match in the case of null "
                                    + "subjectAlternativeNames criteria.",
                        selector.match(cert_1) && selector.match(cert_2));
        
        Collection sans = sans_1.getPairsList();
        selector.setSubjectAlternativeNames(sans);
        assertTrue("The certificate should match the selection criteria.",
                                                    selector.match(cert_1));
        assertFalse("The certificate should not match "
                    + "the selection criteria.",    selector.match(cert_2));
        sans.clear();
        assertTrue("The modification of initialization object "
                    + "should not affect the modification "
                    + "of internal object.",        selector.match(cert_1));
        selector.setSubjectAlternativeNames(sans_2.getPairsList());
        assertTrue("The certificate should match the selection criteria.",
                                                    selector.match(cert_2));
    } catch (IOException e) {
        e.printStackTrace();
        fail("Unexpected IOException was thrown.");
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:60,代码来源:X509CertSelectorTest.java


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