Package org.apache.harmony.security.x509

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


                // 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]
                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));
                    // first check if permited name match
                    constraints = new NameConstraints(subtrees, null);
                    selector.setNameConstraints(constraints.getEncoded());
                    boolean expected = check_matching
                                       || (alternative_names[i][j] == null);
                    assertTrue("The method match() for:\n        "
                               + alternative_names[i][j]
                               + "\nand permited name\n        "
                               + name_constraints[i]
                               + "\nshould return: "+expected,
                               selector.match(certificate) == expected);
                    // second check if excluded name does not match
                    constraints = (check_matching)
                                    // check for 'Any name matching a
                                    // restriction in the excludedSubtrees
                                    // field is invalid regardless of
                                    // information appearing in the 
                                    // permittedSubtrees'.
                                    ? new NameConstraints(subtrees, subtrees)
                                    : new NameConstraints(null, subtrees);
                    selector.setNameConstraints(constraints.getEncoded());
                    expected = !check_matching
                               || (alternative_names[i][j] == null);
                    assertTrue("The method match() for:\n        "
                               + alternative_names[i][j]
                               + "\nand excluded name\n        "
View Full Code Here


                // 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]
                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));
                    // first check if permited name match
                    constraints = new NameConstraints(subtrees, null);
                    selector.setNameConstraints(constraints.getEncoded());
                    boolean expected = check_matching
                                       || (alternative_names[i][j] == null);
                    assertTrue("The method match() for:\n        "
                               + alternative_names[i][j]
                               + "\nand permited name\n        "
                               + name_constraints[i]
                               + "\nshould return: "+expected,
                               selector.match(certificate) == expected);
                    // second check if excluded name does not match
                    constraints = (check_matching)
                                    // check for 'Any name matching a
                                    // restriction in the excludedSubtrees
                                    // field is invalid regardless of
                                    // information appearing in the 
                                    // permittedSubtrees'.
                                    ? new NameConstraints(subtrees, subtrees)
                                    : new NameConstraints(null, subtrees);
                    selector.setNameConstraints(constraints.getEncoded());
                    expected = !check_matching
                               || (alternative_names[i][j] == null);
                    assertTrue("The method match() for:\n        "
                               + alternative_names[i][j]
                               + "\nand excluded name\n        "
View Full Code Here

                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);
                selector.setNameConstraints(constraints.getEncoded());
                assertTrue("The method match() for certificate "
                           + "with subject:\n        "
                           + variants[i][0]
                           + "\nand with alternative name:\n        "
                           + variants[i][1]
                           + "\nand permited name\n        "
                           + variants[i][2]
                           + "\nshould return true",
                           selector.match(certificate));
                // second check if certificate with excluded name doesn't match:
                constraints = new NameConstraints(pos_subtrees, pos_subtrees);
                selector.setNameConstraints(constraints.getEncoded());
                assertTrue("The method match() for certificate "
                           + "with subject:\n        "
                           + variants[i][0]
                           + "\nand with alternative name:\n        "
                           + variants[i][1]
                           + "\nand excluded name\n        "
                           + variants[i][2]
                           + "\nshould return false",
                           !selector.match(certificate));
                // Work with name which is not presented in certificate
                // first check if the certificate without permited name
                // does not match:
                constraints = new NameConstraints(neg_subtrees, null);
                selector.setNameConstraints(constraints.getEncoded());
                assertTrue("The method match() for certificate "
                           + "with subject:\n        "
                           + variants[i][0]
                           + "\nand with alternative name:\n        "
                           + variants[i][1]
                           + "\nand permited name\n        "
                           + variants[i][3]
                           + "\nshould return false",
                           !selector.match(certificate));
                // second check if certificate without excluded name matches:
                constraints = new NameConstraints(neg_subtrees, neg_subtrees);
                selector.setNameConstraints(constraints.getEncoded());
                assertTrue("The method match() for certificate "
                           + "with subject:\n        "
                           + variants[i][0]
                           + "\nand with alternative name:\n        "
                           + variants[i][1]
View Full Code Here

            X509CertSelector selector = new X509CertSelector();

            TestCert cert;
            GeneralSubtrees subtrees;
            NameConstraints constraints;
            for (int i=0; i<names.length; i+=2) {
                // Set up the pathToNames criterion
                ArrayList pathToNames = new ArrayList();
                pathToNames.add(names[i].getAsList());
                selector.setPathToNames(pathToNames);
               
                // 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 "
                            + "as a permitted name so method match() "
                            + "should return true", selector.match(cert));

                constraints = new NameConstraints(subtrees, subtrees);
                cert = new TestCert(constraints);
                assertFalse("The Name Constraints Extension of the "
                            + "certificate contains the name "
                            + "as an excluded name so method match() "
                            + "should return false", selector.match(cert));

                constraints = new NameConstraints(null, subtrees);
                cert = new TestCert(constraints);
                assertFalse("The Name Constraints Extension of the "
                            + "certificate contains the name "
                            + "as an excluded name so method match() "
                            + "should return false", selector.match(cert));
View Full Code Here

            X509CertSelector selector = new X509CertSelector();

            TestCert cert;
            GeneralSubtrees subtrees;
            NameConstraints constraints;
            for (int i=0; i<names.length-2; i+=2) {
                // Set up the pathToNames criterion
                selector.addPathToName(types[i], names[i]);
               
                // 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 "
                            + "certificate contains the name "
                            + "as a permitted name so method match() "
                            + "should return true", selector.match(cert));

                constraints = new NameConstraints(subtrees, subtrees);
                cert = new TestCert(constraints);
                assertFalse("The Name Constraints Extension of the "
                            + "certificate contains the name "
                            + "as an excluded name so method match() "
                            + "should return false", selector.match(cert));

                constraints = new NameConstraints(null, subtrees);
                cert = new TestCert(constraints);
                assertFalse("The Name Constraints Extension of the "
                            + "certificate contains the name "
                            + "as an excluded name so method match() "
                            + "should return false", selector.match(cert));
View Full Code Here

            X509CertSelector selector = new X509CertSelector();

            TestCert cert;
            GeneralSubtrees subtrees;
            NameConstraints constraints;
            for (int i=0; i<names.length-2; i+=2) {
                // Set up the pathToNames criterion
                selector.addPathToName(types[i], names[i]);
               
                // 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 "
                            + "certificate contains the name "
                            + "as a permitted name so method match() "
                            + "should return true", selector.match(cert));

                constraints = new NameConstraints(subtrees, subtrees);
                cert = new TestCert(constraints);
                assertFalse("The Name Constraints Extension of the "
                            + "certificate contains the name "
                            + "as an excluded name so method match() "
                            + "should return false", selector.match(cert));

                constraints = new NameConstraints(null, subtrees);
                cert = new TestCert(constraints);
                assertFalse("The Name Constraints Extension of the "
                            + "certificate contains the name "
                            + "as an excluded name so method match() "
                            + "should return false", selector.match(cert));
View Full Code Here

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

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

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

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

TOP

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

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.