Package sun.security.x509

Examples of sun.security.x509.GeneralNames


                subtrees.addSubtree(subtree);
                // start the checking for each alt. name corresponding
                // to current name_constraints[i]
                boolean check_matching = true;
                for (int j=0; j<alternative_names[i].length; j++) {
                    GeneralNames alt_names_extension = new GeneralNames();
                    if (alternative_names[i][j] == null) {
                        // double trick: turn the switch and check that the
                        // restrictions apply only when the specified name
                        // form is presented.  If no name of the type is in the
                        // certificate, the certificate is acceptable.
                        check_matching = false;
                    } else {
                        alt_names_extension.addName(alternative_names[i][j]);
                    }
                    TestCert certificate = new TestCert(alt_names_extension);
                    certificate.setSubject(x500Subject);
                    certificate.setEncoding(getCertEncoding(nameSubject,
                                                     alt_names_extension));
View Full Code Here


                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:
View Full Code Here

                printAsHex(16, "", " ", _encoded);
                System.out.println("");
                pass = false;
            }

            GeneralNames gNames = new GeneralNames();
            gNames.addName(gName);
            encoded = gNames.getEncoded();
            // manually derived data:
            _encoded = new byte[] {
                (byte) 0x30, (byte) 0x1f, (byte) 0xa5, (byte) 0x1d,
                (byte) 0x80, (byte) 0x0e, (byte) 0x13, (byte) 0x0c,
                (byte) 0x6e, (byte) 0x61, (byte) 0x6d, (byte) 0x65,
View Full Code Here

            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.");
View Full Code Here

            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);
View Full Code Here

        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("");
    }
View Full Code Here

        junit.textui.TestRunner.run(GeneralNamesTest.class);
    }

    public void test_EncodeDecode() throws IOException {
       
        GeneralNames subj_alt_names = new GeneralNames(Arrays
                .asList(new GeneralName[] { new GeneralName(1, "rfc@822.Name"),
                        new GeneralName(2, "dNSName"),
                        new GeneralName(4, "O=Organization"),
                        new GeneralName(6, "http://uniform.Resource.Id"),
                        new GeneralName(7, "255.255.255.0"),
                        new GeneralName(8, "1.2.3.4444.55555") }));
       
        byte[] encoding = GeneralNames.ASN1.encode(subj_alt_names);
       
        GeneralNames gnames = (GeneralNames) GeneralNames.ASN1.decode(encoding);
       
        assertEquals("Names: ", subj_alt_names.getNames(), gnames.getNames());
    }
View Full Code Here

                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:
View Full Code Here

            printAsHex(16, "", " ", _encoded);
            System.out.println("");
            pass = false;
        }

        GeneralNames gNames = new GeneralNames();
        gNames.addName(gName);
        encoded = gNames.getEncoded();
        // manually derived data:
        _encoded = new byte[] {
            (byte) 0x30, (byte) 0x1f, (byte) 0xa5, (byte) 0x1d,
            (byte) 0x80, (byte) 0x0e, (byte) 0x13, (byte) 0x0c,
            (byte) 0x6e, (byte) 0x61, (byte) 0x6d, (byte) 0x65,
View Full Code Here

                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.");
View Full Code Here

TOP

Related Classes of sun.security.x509.GeneralNames

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.