Package org.apache.harmony.security.x509

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


                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


                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

        try {
            Name nameSubject = new Name(subject);
            for (int i=0; i<name_constraints.length; i++) {
                // make the subtrees (part of name constraints)
                // this subtrees will be used as permited and as excluded
                GeneralSubtree subtree =
                    new GeneralSubtree(name_constraints[i]);
                GeneralSubtrees subtrees = new GeneralSubtrees();
                NameConstraints constraints;
                subtrees.addSubtree(subtree);
                // start the checking for each alt. name corresponding
                // to current name_constraints[i]
View Full Code Here

        try {
            Name nameSubject = new Name(subject);
            for (int i=0; i<name_constraints.length; i++) {
                // make the subtrees (part of name constraints)
                // this subtrees will be used as permited and as excluded
                GeneralSubtree subtree =
                    new GeneralSubtree(name_constraints[i]);
                GeneralSubtrees subtrees = new GeneralSubtrees();
                NameConstraints constraints;
                subtrees.addSubtree(subtree);
                // start the checking for each alt. name corresponding
                // to current name_constraints[i]
View Full Code Here

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

               
                // Construct the subtrees without the current name
                subtrees = new GeneralSubtrees();
                for (int j=0; j<names.length; j++) {
                    if (i != j && i+1 != j) {
                        subtrees.addSubtree(new GeneralSubtree(names[j]));
                    }
                }
                constraints = new NameConstraints(subtrees, null);
                cert = new TestCert(constraints);
                assertTrue("The Name Constraints Extension of the "
                            + "certificate does not contain the names "
                            + "of such type so method match() should "
                            + "return true.", selector.match(cert));

                constraints = new NameConstraints(subtrees, subtrees);
                cert = new TestCert(constraints);
                assertTrue("The Name Constraints Extension of the "
                            + "certificate does not contain the names "
                            + "of such type so method match() should "
                            + "return true.", selector.match(cert));

                constraints = new NameConstraints(null, subtrees);
                cert = new TestCert(constraints);
                assertTrue("The Name Constraints Extension of the "
                            + "certificate does not contain the names "
                            + "of such type so method match() should "
                            + "return true.", selector.match(cert));

                subtrees.addSubtree(new GeneralSubtree(names[i+1]));

                constraints = new NameConstraints(subtrees, null);
                cert = new TestCert(constraints);
                assertFalse("The Name Constraints Extension of the "
                            + "certificate does not contain the name "
                            + "as a permitted name so method match() "
                            + "should return false", selector.match(cert));

                constraints = new NameConstraints(subtrees, subtrees);
                cert = new TestCert(constraints);
                assertFalse("The Name Constraints Extension of the "
                            + "certificate does not contain the name "
                            + "as an excluded name but it does not "
                            + "contain this name as a permitted so match()"
                            + "should return false", selector.match(cert));

                constraints = new NameConstraints(null, subtrees);
                cert = new TestCert(constraints);
                assertTrue("The Name Constraints Extension of the "
                            + "certificate does not contain the name "
                            + "as an excluded name so method match() "
                            + "should return true", selector.match(cert));

                subtrees.addSubtree(new GeneralSubtree(names[i]));

                constraints = new NameConstraints(subtrees, null);
                cert = new TestCert(constraints);
                assertTrue("The Name Constraints Extension of the "
                            + "certificate contains the name "
View Full Code Here

                // Construct the subtrees without the current name
                subtrees = new GeneralSubtrees();
                for (int j=i+2; j<names.length; j++) {
                    if (i != j && i+1 != j) {
                        subtrees.addSubtree(
                                new GeneralSubtree(
                                    new GeneralName(types[j], names[j])));
                    }
                }
                constraints = new NameConstraints(subtrees, null);
                cert = new TestCert(constraints);
                assertTrue("The Name Constraints Extension of the "
                            + "certificate does not contain the names "
                            + "of such type so method match() should "
                            + "return true.", selector.match(cert));

                constraints = new NameConstraints(subtrees, subtrees);
                cert = new TestCert(constraints);
                assertTrue("The Name Constraints Extension of the "
                            + "certificate does not contain the names "
                            + "of such type so method match() should "
                            + "return true.", selector.match(cert));

                constraints = new NameConstraints(null, subtrees);
                cert = new TestCert(constraints);
                assertTrue("The Name Constraints Extension of the "
                            + "certificate does not contain the names "
                            + "of such type so method match() should "
                            + "return true.", selector.match(cert));

                subtrees.addSubtree(
                        new GeneralSubtree(
                            new GeneralName(types[i+1], names[i+1])));

                constraints = new NameConstraints(subtrees, null);
                cert = new TestCert(constraints);
                assertFalse("The Name Constraints Extension of the "
                            + "certificate does not contain the name "
                            + "as a permitted name so method match() "
                            + "should return false", selector.match(cert));

                constraints = new NameConstraints(subtrees, subtrees);
                cert = new TestCert(constraints);
                assertFalse("The Name Constraints Extension of the "
                            + "certificate does not contain the name "
                            + "as an excluded name but it does not "
                            + "contain this name as a permitted so match()"
                            + "should return false", selector.match(cert));

                constraints = new NameConstraints(null, subtrees);
                cert = new TestCert(constraints);
                assertTrue("The Name Constraints Extension of the "
                            + "certificate does not contain the name "
                            + "as an excluded name so method match() "
                            + "should return true", selector.match(cert));

                subtrees.addSubtree(
                        new GeneralSubtree(
                            new GeneralName(types[i], names[i])));

                constraints = new NameConstraints(subtrees, null);
                cert = new TestCert(constraints);
                assertTrue("The Name Constraints Extension of the "
View Full Code Here

TOP

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

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.