Package org.apache.harmony.security.x509

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


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


    /**
     * @com.intel.drl.spec_ref
     */
    public void addSubjectAlternativeName(int tag, String name)
                                                       throws IOException {
        GeneralName alt_name = new GeneralName(tag, name);
        // create only if there was not any errors
        if (subjectAltNames == null) {
            subjectAltNames = new ArrayList[9];
        }
        if (subjectAltNames[tag] == null) {
View Full Code Here

    /**
     * @com.intel.drl.spec_ref
     */
    public void addSubjectAlternativeName(int tag, byte[] name)
                                            throws IOException {
        GeneralName alt_name = new GeneralName(tag, name);
        // create only if there was not any errors
        if (subjectAltNames == null) {
            subjectAltNames = new ArrayList[9];
        }
        if (subjectAltNames[tag] == null) {
View Full Code Here

    /**
     * @com.intel.drl.spec_ref
     */
    public void addPathToName(int type, String name) throws IOException {
        GeneralName path_name = new GeneralName(type, name);
        // create only if there was not any errors
        if (pathToNames == null) {
            pathToNames = new ArrayList();
        }
        pathToNames.add(path_name);
View Full Code Here

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

        HashSet extKeyUsage = new HashSet(Arrays.asList(new String[] {
                "1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2", "1.3.6.1.5.5.7.3.3",
                "1.3.6.1.5.5.7.3.4", "1.3.6.1.5.5.7.3.8", "1.3.6.1.5.5.7.3.9",
                "1.3.6.1.5.5.7.3.5", "1.3.6.1.5.5.7.3.6", "1.3.6.1.5.5.7.3.7"}
        ));
        GeneralNames subjectAltNames = new GeneralNames(Arrays.asList(
            new GeneralName[] {
                new GeneralName(1, "rfc@822.Name"),
                new GeneralName(2, "dNSName"),
                new GeneralName(6, "http://uniform.Resource.Id"),
                new GeneralName(7, "1.1.1.1")
            }
        ));
        String[] policies = new String[] {
            "0.0.0.0.0.0",
            "1.1.1.1.1.1",
        };
        TestCert cert = new TestCert("certificate equality criteria");
       
        X509CertSelector selector = new X509CertSelector();
        selector.setCertificate(cert);
        selector.setSerialNumber(serial);
        selector.setIssuer(issuer);
        selector.setSubject(subject);
        selector.setSubjectKeyIdentifier(subject_auth_KeyID);
        selector.setAuthorityKeyIdentifier(subject_auth_KeyID);
        selector.setCertificateValid(certValid);
        selector.setPrivateKeyValid(privateKeyValid[1]);
        selector.setSubjectPublicKey(pkey);
        selector.setSubjectPublicKeyAlgID(pkAlgID);
        selector.setKeyUsage(keyUsage);
        selector.setExtendedKeyUsage(extKeyUsage);
        selector.setSubjectAlternativeNames(subjectAltNames.getPairsList());
        selector.setMatchAllSubjectAltNames(true);
        selector.setPolicy(new HashSet(Arrays.asList(policies)));

        assertNotNull("The result should not be null.",
                selector.toString());
View Full Code Here

        HashSet extKeyUsage = new HashSet(Arrays.asList(new String[] {
                "1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2", "1.3.6.1.5.5.7.3.3",
                "1.3.6.1.5.5.7.3.4", "1.3.6.1.5.5.7.3.8", "1.3.6.1.5.5.7.3.9",
                "1.3.6.1.5.5.7.3.5", "1.3.6.1.5.5.7.3.6", "1.3.6.1.5.5.7.3.7"}
        ));
        GeneralNames subjectAltNames = new GeneralNames(Arrays.asList(
            new GeneralName[] {
                new GeneralName(1, "rfc@822.Name"),
                new GeneralName(2, "dNSName"),
                new GeneralName(6, "http://uniform.Resource.Id"),
                new GeneralName(7, "1.1.1.1")
            }
        ));
        String[] policies = new String[] {
            "0.0.0.0.0.0",
            "1.1.1.1.1.1",
        };
       
        TestCert cert = new TestCert("certificate equality criteria");
        cert.setSerialNumber(serial);
        cert.setIssuer(issuer);
        cert.setSubject(subject);
        cert.setKeyIdentifier(subject_auth_KeyID);
        cert.setDate(certValid);
        cert.setPeriod(privateKeyValid[0], privateKeyValid[2]);
        cert.setPublicKey(pkey);
        cert.setKeyUsage(keyUsage);
        cert.setExtendedKeyUsage(extKeyUsage);
        cert.setSubjectAlternativeNames(subjectAltNames);
        cert.setPolicies(policies);
           
        X509CertSelector selector = new X509CertSelector();
        selector.setCertificate(cert);
        selector.setSerialNumber(serial);
        selector.setIssuer(issuer);
        selector.setSubject(subject);
        selector.setSubjectKeyIdentifier(subject_auth_KeyID);
        selector.setAuthorityKeyIdentifier(subject_auth_KeyID);
        selector.setCertificateValid(certValid);
        selector.setPrivateKeyValid(privateKeyValid[1]);
        selector.setSubjectPublicKey(pkey);
        selector.setSubjectPublicKeyAlgID(pkAlgID);
        selector.setKeyUsage(keyUsage);
        selector.setExtendedKeyUsage(extKeyUsage);
        selector.setSubjectAlternativeNames(subjectAltNames.getPairsList());
        selector.setMatchAllSubjectAltNames(true);
        selector.setPolicy(new HashSet(Arrays.asList(policies)));

        assertFalse("The null object should not match",
                                    selector.match((X509Certificate) null));
View Full Code Here

        HashSet extKeyUsage = new HashSet(Arrays.asList(new String[] {
                "1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2", "1.3.6.1.5.5.7.3.3",
                "1.3.6.1.5.5.7.3.4", "1.3.6.1.5.5.7.3.8", "1.3.6.1.5.5.7.3.9",
                "1.3.6.1.5.5.7.3.5", "1.3.6.1.5.5.7.3.6", "1.3.6.1.5.5.7.3.7"}
        ));
        GeneralNames subjectAltNames = new GeneralNames(Arrays.asList(
            new GeneralName[] {
                new GeneralName(1, "rfc@822.Name"),
                new GeneralName(2, "dNSName"),
                new GeneralName(6, "http://uniform.Resource.Id"),
                new GeneralName(7, "1.1.1.1")
            }
        ));
        String[] policies = new String[] {
            "0.0.0.0.0.0",
            "1.1.1.1.1.1",
        };
       
        TestCert cert = new TestCert("certificate equality criteria");
        cert.setSerialNumber(serial);
        cert.setIssuer(issuer);
        cert.setSubject(subject);
        cert.setKeyIdentifier(subject_auth_KeyID);
        cert.setDate(certValid);
        cert.setPeriod(privateKeyValid[0], privateKeyValid[2]);
        cert.setPublicKey(pkey);
        cert.setKeyUsage(keyUsage);
        cert.setExtendedKeyUsage(extKeyUsage);
        cert.setSubjectAlternativeNames(subjectAltNames);
        cert.setPolicies(policies);
           
        X509CertSelector selector = new X509CertSelector();
        selector.setCertificate(cert);
        selector.setSerialNumber(serial);
        selector.setIssuer(issuer);
        selector.setSubject(subject);
        selector.setSubjectKeyIdentifier(subject_auth_KeyID);
        selector.setAuthorityKeyIdentifier(subject_auth_KeyID);
        selector.setCertificateValid(certValid);
        selector.setPrivateKeyValid(privateKeyValid[1]);
        selector.setSubjectPublicKey(pkey);
        selector.setSubjectPublicKeyAlgID(pkAlgID);
        selector.setKeyUsage(keyUsage);
        selector.setExtendedKeyUsage(extKeyUsage);
        selector.setSubjectAlternativeNames(subjectAltNames.getPairsList());
        selector.setMatchAllSubjectAltNames(true);
        selector.setPolicy(new HashSet(Arrays.asList(policies)));

        assertTrue("The certificate should match the selector",
                            ((X509CertSelector)selector.clone()).match(cert));
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

        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);
        sans_1.addName(san6);
        sans_1.addName(san7);
        sans_1.addName(san8);
        GeneralNames sans_2 = new GeneralNames();
        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);
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.