Package org.apache.harmony.security.x509

Examples of org.apache.harmony.security.x509.DistributionPoint


        boolean[] subjectUniqueID = new boolean[]
                    {false, true, false, true, false, true, false, true};

        Extension extension = new Extension("2.5.29.17",
                                            true, subjectAltNames.getEncoded());
        Extensions extensions = new Extensions();
        extensions.addExtension(extension);
      
        TBSCertificate tbsCertificate = new TBSCertificate(version,
                serialNumber, signature, issuer, validity, subject,
                subjectPublicKeyInfo, issuerUniqueID, subjectUniqueID,
                extensions);
View Full Code Here


    /**
     * 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, "rfc@822.Name");
            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);
View Full Code Here

        String name4 = "O=Organization";
        String name6 = "http://uniform.Resource.Id";
        String name7 = "255.255.255.0";
        String name8 = "1.2.3.4444.55555";

        GeneralName san1 = new GeneralName(1, name1);
        GeneralName san2 = new GeneralName(2, name2);
        GeneralName san4 = new GeneralName(4, name4);
        GeneralName san6 = new GeneralName(6, name6);
        GeneralName san7 = new GeneralName(7, name7);
        GeneralName san8 = new GeneralName(8, name8);

        GeneralNames sans_1 = new GeneralNames();
        sans_1.addName(san1);
        sans_1.addName(san2);
        sans_1.addName(san4);
View Full Code Here

    /**
     * addSubjectAlternativeName(int type, byte[] name) method testing.
     */
    public void testAddSubjectAlternativeName2() {
        try {
            GeneralName san0 =
                new GeneralName(new OtherName("1.2.3.4.5",
                        ASN1Integer.getInstance().encode(
                                BigInteger.valueOf(55L).toByteArray())
                            ));
            GeneralName san1 = new GeneralName(1, "rfc@822.Name");
            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(new byte[] {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);
            sans_2.addName(san1);
            sans_2.addName(san2);
           
            TestCert cert_1 = new TestCert(sans_1);
            TestCert cert_2 = new TestCert(sans_2);
            X509CertSelector selector = new X509CertSelector();
            selector.setMatchAllSubjectAltNames(true);

            selector.addSubjectAlternativeName(0, san0.getEncodedName());
            assertTrue("The certificate should match the selection criteria.",
                                                        selector.match(cert_1));
            assertTrue("The certificate should match the selection criteria.",
                                                        selector.match(cert_2));
            selector.addSubjectAlternativeName(1, san1.getEncodedName());
            assertTrue("The certificate should match the selection criteria.",
                                                        selector.match(cert_1));
            assertTrue("The certificate should match the selection criteria.",
                                                        selector.match(cert_2));
            selector.addSubjectAlternativeName(2, san2.getEncodedName());
            assertTrue("The certificate should match the selection criteria.",
                                                        selector.match(cert_1));
            assertTrue("The certificate should match the selection criteria.",
                                                        selector.match(cert_2));
            selector.addSubjectAlternativeName(3, san3.getEncodedName());
            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));
            selector.addSubjectAlternativeName(4, san4.getEncodedName());
            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));
            selector.addSubjectAlternativeName(5, san5.getEncodedName());
            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));
            selector.addSubjectAlternativeName(6, san6.getEncodedName());
            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));
            selector.addSubjectAlternativeName(7, san7.getEncodedName());
            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));
            byte[] oid = san8.getEncodedName();
            selector.addSubjectAlternativeName(8, oid);
            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));
View Full Code Here

    /**
     * getSubjectAlternativeNames() method testing.
     */
    public void testGetSubjectAlternativeNames() {
        try {
            GeneralName san1 = new GeneralName(1, "rfc@822.Name");
            GeneralName san2 = new GeneralName(2, "dNSName");

            GeneralNames sans = new GeneralNames();
            sans.addName(san1);
            sans.addName(san2);

View Full Code Here

    /**
     * setMatchAllSubjectAltNames(boolean matchAllNames) method testing.
     */
    public void testSetMatchAllSubjectAltNames() {
        try {
            GeneralName san1 = new GeneralName(1, "rfc@822.Name");
            GeneralName san2 = new GeneralName(2, "dNSName");

            GeneralNames sans_1 = new GeneralNames();
            sans_1.addName(san1);
            GeneralNames sans_2 = new GeneralNames();
            sans_2.addName(san1);
View Full Code Here

        // Restrictions apply only when the specified name form is present. 
        // If no name of the type is in the certificate,
        // the certificate is acceptable (rfc 3280).
       
        GeneralName [] name_constraints = new GeneralName[] {
            new GeneralName(1, "822.Name"),
            new GeneralName(1, "rfc@822.Name"),
            new GeneralName(2, "Name.org"),
            new GeneralName(2, "dNS.Name.org"),
            //new GeneralName(4, "O=Organization"),
            new GeneralName(6, "http://.Resource.Id"),
            new GeneralName(6, "http://uniform.Resource.Id"),
            new GeneralName(7, "1.1.1.1"),
            // new GeneralName(7, new byte[] {1, 1, 1, 1, 3, 3, 3, 3}),
            new GeneralName(new byte[] {1, 1, 1, 1, 1, 1, 1, 1,
                                        1, 1, 1, 1, 1, 1, 1, 1}),
            // new GeneralName(7, new byte[] {1, 1, 1, 1, 1, 1, 1, 1,
            //                                1, 1, 1, 1, 1, 1, 1, 1,
            //                                3, 3, 3, 3, 3, 3, 3, 3,
            //                                3, 3, 3, 3, 3, 3, 3, 3})
        };

        // names which should match divided from names which should not
        // match by null
        GeneralName[][] alternative_names = new GeneralName[][] {
            {
                new GeneralName(1, "rfc@822.Name"),
                null,
                new GeneralName(1, "rfc@Other.Name")
            }, {
                new GeneralName(1, "rfc@822.Name"),
                null,
                new GeneralName(1, "rfc@Other.Name")
            }, {
                new GeneralName(2, "Name.org"),
                new GeneralName(2, "dNS.Name.org"),
                null,
                new GeneralName(2, "dNS.OtherName.org")
            }, {
                new GeneralName(2, "dNS.Name.org"),
                null,
                new GeneralName(2, "Name.org"),
                new GeneralName(2, "dNS.OtherName.org")
            }, {
               
            //    new GeneralName(4, "O=Organization"),
            //    null,
            //    new GeneralName(4, "O=OtherOrganization")
            //}, {
           
                new GeneralName(6, "http://uniform.Resource.Id/location"),
                null,
                //new GeneralName(6, "http://Resource.Id")
            }, {
                new GeneralName(6, "http://uniform.Resource.Id"),
                null,
                new GeneralName(6, "http://Resource.Id")
            }, {
                new GeneralName(new byte[] {1, 1, 1, 1}),
                null,
                new GeneralName(new byte[] {2, 2, 2, 2})
            // }, {
            //     new GeneralName(7, new byte[] {1, 1, 1, 1}),
            //     new GeneralName(7, new byte[] {2, 2, 2, 2}),
            //     new GeneralName(7, new byte[] {3, 3, 3, 3}),
            //     null,
            //     new GeneralName(7, new byte[] {4, 4, 4, 4})
            }, {
                new GeneralName(new byte[] {1, 1, 1, 1, 1, 1, 1, 1,
                                            1, 1, 1, 1, 1, 1, 1, 1}),
                null,
                new GeneralName(new byte[] {2, 2, 2, 2, 2, 2, 2, 2,
                                            2, 2, 2, 2, 2, 2, 2, 2}),
            // }, {
            //     new GeneralName(7, new byte[] {1, 1, 1, 1, 1, 1, 1, 1,
            //                                    1, 1, 1, 1, 1, 1, 1, 1}),
            //     new GeneralName(7, new byte[] {2, 2, 2, 2, 2, 2, 2, 2,
View Full Code Here

     * GeneralNames of types: 1, 2, 6, 7 and set it as a criterion.
     */
    public void testSetNameConstraints1() throws IOException {

        GeneralName [] name_constraints = new GeneralName[] {
            new GeneralName(1, "822.Name"),
            new GeneralName(1, "rfc@822.Name"),
            new GeneralName(2, "Name.org"),
            new GeneralName(2, "dNS.Name.org"),
            new GeneralName(6, "http://.Resource.Id"),
            new GeneralName(6, "http://uniform.Resource.Id"),
            new GeneralName(7, "1.1.1.1"),
            new GeneralName(7, "1.1.1.1/3.3.3.3"),
            new GeneralName(7, "0101:0101:0101:0101:0101:0101:0101:0101"),
            new GeneralName(7, "0101:0101:0101:0101:0101:0101:0101:0101"
                            + "/0303:0303:0303:0303:0303:0303:0303:0303"),
        };

        // Names which should match divided from names which should not
        // match by null.
        // Restrictions apply only when the specified name form is present. 
        // If no name of the type is in the certificate, the certificate
        // is acceptable (rfc 3280). This assertion is checked during processing
        // of null GeneralName object (it also serves as separator).
        GeneralName[][] alternative_names = new GeneralName[][] {
            {
                new GeneralName(1, "rfc@822.Name"),
                null,
                new GeneralName(1, "rfc@Other.Name")
            }, {
                new GeneralName(1, "rfc@822.Name"),
                null,
                new GeneralName(1, "rfc@Other.Name")
            }, {
                new GeneralName(2, "Name.org"),
                new GeneralName(2, "dNS.Name.org"),
                null,
                new GeneralName(2, "dNS.OtherName.org")
            }, {
                new GeneralName(2, "dNS.Name.org"),
                null,
                new GeneralName(2, "Name.org"),
                new GeneralName(2, "dNS.OtherName.org")
            }, {
               
                new GeneralName(6, "http://uniform.Resource.Id/location"),
                null,
                new GeneralName(6, "http://Resource.Id")
            }, {
                new GeneralName(6, "http://uniform.Resource.Id"),
                null,
                new GeneralName(6, "http://Resource.Id")
            }, {
                new GeneralName(new byte[] {1, 1, 1, 1}),
                null,
                new GeneralName(new byte[] {2, 2, 2, 2})
            }, {
                new GeneralName(new byte[] {1, 1, 1, 1}),
                new GeneralName(new byte[] {2, 2, 2, 2}),
                new GeneralName(new byte[] {3, 3, 3, 3}),
                null,
                new GeneralName(new byte[] {4, 4, 4, 4})
            }, {
                new GeneralName(new byte[] {1, 1, 1, 1, 1, 1, 1, 1,
                                            1, 1, 1, 1, 1, 1, 1, 1}),
                null,
                new GeneralName(new byte[] {2, 2, 2, 2, 2, 2, 2, 2,
                                            2, 2, 2, 2, 2, 2, 2, 2}),
            }, {
                new GeneralName(new byte[] {1, 1, 1, 1, 1, 1, 1, 1,
                                            1, 1, 1, 1, 1, 1, 1, 1}),
                new GeneralName(new byte[] {2, 2, 2, 2, 2, 2, 2, 2,
                                            2, 2, 2, 2, 2, 2, 2, 2}),
                new GeneralName(new byte[] {3, 3, 3, 3, 3, 3, 3, 3,
                                            3, 3, 3, 3, 3, 3, 3, 3}),
                null,
                new GeneralName(new byte[] {4, 4, 4, 4, 4, 4, 4, 4,
                                            4, 4, 4, 4, 4, 4, 4, 4}),
            }
        };

        X509CertSelector selector = new X509CertSelector();
View Full Code Here

        try {
            for (int i=0; i<variants.length; i++) {
                // make the names objects
                X500Principal subject = new X500Principal(variants[i][0]);
                Name subject_name = new Name(variants[i][0]);
                GeneralName alt_name = new GeneralName(4, variants[i][1]);
                // make the certificate to be checked
                GeneralNames alt_names_extension = new GeneralNames();
                alt_names_extension.addName(alt_name);
                TestCert certificate = new TestCert(alt_names_extension);
                certificate.setSubject(subject);
                certificate.setEncoding(getCertEncoding(subject_name,
                                                 alt_names_extension));
                // make the subtrees (part of name constraints)
                // this subtrees will be used as permited and as excluded
                // name which is presented in certificate:
                GeneralSubtrees pos_subtrees = new GeneralSubtrees();
                pos_subtrees.addSubtree(
                        new GeneralSubtree(
                            new GeneralName(4, variants[i][2])));
                // name which is absent in certificate:
                GeneralSubtrees neg_subtrees = new GeneralSubtrees();
                neg_subtrees.addSubtree(
                        new GeneralSubtree(
                            new GeneralName(4, variants[i][3])));

                NameConstraints constraints;
                // Work with name which is presented in certificate
                // first check if certificate with permited name matches:
                constraints = new NameConstraints(pos_subtrees, null);
View Full Code Here

     * setPathToNames(Collection<List<?>> names) method testing.
     */
    public void testSetPathToNames() {
        try {
            GeneralName[] names = new GeneralName[] {
                new GeneralName(1, "rfc@822.Name"),
                new GeneralName(1, "rfc@822.AnotherName"),
                new GeneralName(2, "dNSName"),
                new GeneralName(2, "AnotherdNSName"),
                new GeneralName(4, "O=Organization"),
                new GeneralName(4, "O=Another Organization"),
                new GeneralName(6, "http://uniform.Resource.Id"),
                new GeneralName(6, "http://another.uniform.Resource.Id"),
                new GeneralName(7, "1.1.1.1"),
                new GeneralName(7, "2.2.2.2")
            };

            X509CertSelector selector = new X509CertSelector();

            TestCert cert;
View Full Code Here

TOP

Related Classes of org.apache.harmony.security.x509.DistributionPoint

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.