Package org.apache.harmony.security.x509

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


                new Certificate(
                    new TBSCertificate(2, certSerialNumber1, signature,
                        new Name(certIssuerName),
                        new Validity(new Date(), new Date()),
                    new Name(certIssuerName),
                    new SubjectPublicKeyInfo(signature, new byte[10]),
                    null, null, null),
                signature, new byte[10]));
            X509CertImpl cert2 = new X509CertImpl(
                new Certificate(
                    new TBSCertificate(2, certSerialNumber2, signature,
                        new Name(certIssuerName),
                        new Validity(new Date(), new Date()),
                    new Name(certIssuerName),
                    new SubjectPublicKeyInfo(signature, new byte[10]),
                    null, null, null),
                signature, new byte[10]));
            X509CertImpl cert3 = new X509CertImpl(
                new Certificate(
                    new TBSCertificate(2, certSerialNumber3, signature,
                        new Name("O=Another Cert Issuer"),
                        new Validity(new Date(), new Date()),
                    new Name(certIssuerName),
                    new SubjectPublicKeyInfo(signature, new byte[10]),
                    null, null, null),
                signature, new byte[10]));
            assertFalse("Certificate should not be presented in CRL "
                    + "because issuer is not the same as CRL issuer",
                    crl.isRevoked(cert1));
View Full Code Here


            SubjectPublicKeyInfo.ASN1.decode(publicKey.getEncoded());
        keyEncoding = subjectPublicKeyInfo.getEncoded();

        Extensions exts = new Extensions(Arrays.asList(extensions));
      
        TBSCertificate tbsCertificate =
            new TBSCertificate(version, serialNumber,
                signature, issuer, validity, subject, subjectPublicKeyInfo,
                issuerUniqueID, subjectUniqueID, exts);
        tbsCertEncoding = tbsCertificate.getEncoded();
      
        if (signatureValueBytes == null) {
            try {
                Signature sig= Signature.getInstance("DSA");//new byte[32];
                sig.initSign(privateKey);
View Full Code Here

        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);

        // make the Certificate
View Full Code Here

     */
    public void testGetRevokedCertificate1() {
        try {
            X509CertImpl cert1 = new X509CertImpl(
                new Certificate(
                    new TBSCertificate(2, certSerialNumber1, signature,
                        new Name(certIssuerName),
                        new Validity(new Date(), new Date()),
                    new Name(certIssuerName),
                    new SubjectPublicKeyInfo(signature, new byte[10]),
                    null, null, null),
                signature, new byte[10]));
            X509CertImpl cert2 = new X509CertImpl(
                new Certificate(
                    new TBSCertificate(2, certSerialNumber2, signature,
                        new Name(certIssuerName),
                        new Validity(new Date(), new Date()),
                    new Name(certIssuerName),
                    new SubjectPublicKeyInfo(signature, new byte[10]),
                    null, null, null),
                signature, new byte[10]));
            X509CertImpl cert3 = new X509CertImpl(
                new Certificate(
                    new TBSCertificate(2, certSerialNumber3, signature,
                        new Name("O=Another Cert Issuer"),
                        new Validity(new Date(), new Date()),
                    new Name(certIssuerName),
                    new SubjectPublicKeyInfo(signature, new byte[10]),
                    null, null, null),
View Full Code Here

     */
    public void testIsRevoked() {
        try {
            X509CertImpl cert1 = new X509CertImpl(
                new Certificate(
                    new TBSCertificate(2, certSerialNumber1, signature,
                        new Name(certIssuerName),
                        new Validity(new Date(), new Date()),
                    new Name(certIssuerName),
                    new SubjectPublicKeyInfo(signature, new byte[10]),
                    null, null, null),
                signature, new byte[10]));
            X509CertImpl cert2 = new X509CertImpl(
                new Certificate(
                    new TBSCertificate(2, certSerialNumber2, signature,
                        new Name(certIssuerName),
                        new Validity(new Date(), new Date()),
                    new Name(certIssuerName),
                    new SubjectPublicKeyInfo(signature, new byte[10]),
                    null, null, null),
                signature, new byte[10]));
            X509CertImpl cert3 = new X509CertImpl(
                new Certificate(
                    new TBSCertificate(2, certSerialNumber3, signature,
                        new Name("O=Another Cert Issuer"),
                        new Validity(new Date(), new Date()),
                    new Name(certIssuerName),
                    new SubjectPublicKeyInfo(signature, new byte[10]),
                    null, null, null),
View Full Code Here

    protected void setUp() throws java.lang.Exception {
        AlgorithmIdentifier signature =
            new AlgorithmIdentifier(algOID, algParams);
        Name issuer = new Name(issuerName);
        Name subject = new Name(subjectName);
        Validity validity =
            new Validity(new Date(notBefore), new Date(notAfter));

        SubjectPublicKeyInfo subjectPublicKeyInfo = (SubjectPublicKeyInfo)
            SubjectPublicKeyInfo.ASN1.decode(publicKey.getEncoded());
        keyEncoding = subjectPublicKeyInfo.getEncoded();
View Full Code Here

        // make the TBSCertificate for Certificate
        int version = 2; //v3
        BigInteger serialNumber = BigInteger.valueOf(555L);
        AlgorithmIdentifier signature = new AlgorithmIdentifier("1.2.3.44.555");
        Name issuer = new Name("O=Certificate Issuer");
        Validity validity = new Validity(new Date(100000000),
                                         new Date(200000000));
        SubjectPublicKeyInfo subjectPublicKeyInfo =
            new SubjectPublicKeyInfo(
                    new AlgorithmIdentifier("1.2.840.113549.1.1.2"),
                                            new byte[10]);
View Full Code Here

        try {
            X509CertImpl cert1 = new X509CertImpl(
                new Certificate(
                    new TBSCertificate(2, certSerialNumber1, signature,
                        new Name(certIssuerName),
                        new Validity(new Date(), new Date()),
                    new Name(certIssuerName),
                    new SubjectPublicKeyInfo(signature, new byte[10]),
                    null, null, null),
                signature, new byte[10]));
            X509CertImpl cert2 = new X509CertImpl(
                new Certificate(
                    new TBSCertificate(2, certSerialNumber2, signature,
                        new Name(certIssuerName),
                        new Validity(new Date(), new Date()),
                    new Name(certIssuerName),
                    new SubjectPublicKeyInfo(signature, new byte[10]),
                    null, null, null),
                signature, new byte[10]));
            X509CertImpl cert3 = new X509CertImpl(
                new Certificate(
                    new TBSCertificate(2, certSerialNumber3, signature,
                        new Name("O=Another Cert Issuer"),
                        new Validity(new Date(), new Date()),
                    new Name(certIssuerName),
                    new SubjectPublicKeyInfo(signature, new byte[10]),
                    null, null, null),
                signature, new byte[10]));
            assertNull("Certificate should not be presented in CRL "
View Full Code Here

        try {
            X509CertImpl cert1 = new X509CertImpl(
                new Certificate(
                    new TBSCertificate(2, certSerialNumber1, signature,
                        new Name(certIssuerName),
                        new Validity(new Date(), new Date()),
                    new Name(certIssuerName),
                    new SubjectPublicKeyInfo(signature, new byte[10]),
                    null, null, null),
                signature, new byte[10]));
            X509CertImpl cert2 = new X509CertImpl(
                new Certificate(
                    new TBSCertificate(2, certSerialNumber2, signature,
                        new Name(certIssuerName),
                        new Validity(new Date(), new Date()),
                    new Name(certIssuerName),
                    new SubjectPublicKeyInfo(signature, new byte[10]),
                    null, null, null),
                signature, new byte[10]));
            X509CertImpl cert3 = new X509CertImpl(
                new Certificate(
                    new TBSCertificate(2, certSerialNumber3, signature,
                        new Name("O=Another Cert Issuer"),
                        new Validity(new Date(), new Date()),
                    new Name(certIssuerName),
                    new SubjectPublicKeyInfo(signature, new byte[10]),
                    null, null, null),
                signature, new byte[10]));
            assertFalse("Certificate should not be presented in CRL "
View Full Code Here

        PublicKey           intPubKey  = fact.generatePublic(intPubKeySpec);
        PrivateKey          privKey    = fact.generatePrivate(privKeySpec);
        PublicKey           pubKey     = fact.generatePublic(pubKeySpec);
       
        X509Certificate     trustCert       = createTrustCert(caPubKey, caPrivKey);
        CertificatePolicies intPolicies     = null;
        Hashtable           map             = null;
        ASN1EncodableVector policies        = null;
        Set                 requirePolicies = null;
        X509Certificate     intCert         = null;
        X509Certificate     endCert         = null;
       
        /**
         * valid test_00
         */
        intPolicies = new CertificatePolicies(new PolicyInformation(new ASN1ObjectIdentifier("2.5.29.32.0")));
        map = new Hashtable();
        map.put("2.16.840.1.101.3.2.1.48.1","2.16.840.1.101.3.2.1.48.2");
        intCert = createIntmedCert(intPubKey, caPrivKey, caPubKey, intPolicies, map);
       
        policies   = new ASN1EncodableVector();
        policies.add(new PolicyInformation(new ASN1ObjectIdentifier("2.16.840.1.101.3.2.1.48.2")));
        endCert = createEndEntityCert(pubKey, intPrivKey, intPubKey, policies);
       
        requirePolicies = null;
        String msg = testPolicies(0, trustCert, intCert, endCert, requirePolicies, true);
        checkMessage(0, msg, "");
       
        /**
         * test_01
         */
        intPolicies = new CertificatePolicies(new PolicyInformation(new ASN1ObjectIdentifier("2.5.29.32.0")));
        map = new Hashtable();
        map.put("2.16.840.1.101.3.2.1.48.1","2.16.840.1.101.3.2.1.48.2");
        intCert = createIntmedCert(intPubKey, caPrivKey, caPubKey, intPolicies, map);
       
        policies   = new ASN1EncodableVector();
        policies.add(new PolicyInformation(new ASN1ObjectIdentifier("2.16.840.1.101.3.2.1.48.2")));
        endCert = createEndEntityCert(pubKey, intPrivKey, intPubKey, policies);
       
        requirePolicies = new HashSet();
        requirePolicies.add("2.16.840.1.101.3.2.1.48.1");
        msg = testPolicies(1, trustCert, intCert, endCert, requirePolicies, true);
        checkMessage(1, msg, "");
       
        /**
         * test_02
         */
        intPolicies = new CertificatePolicies(new PolicyInformation(new ASN1ObjectIdentifier("2.5.29.32.0")));
        map = new Hashtable();
        map.put("2.16.840.1.101.3.2.1.48.1","2.16.840.1.101.3.2.1.48.2");
        intCert = createIntmedCert(intPubKey, caPrivKey, caPubKey, intPolicies, map);
       
        policies   = new ASN1EncodableVector();
        policies.add(new PolicyInformation(new ASN1ObjectIdentifier("2.16.840.1.101.3.2.1.48.2")));
        endCert = createEndEntityCert(pubKey, intPrivKey, intPubKey, policies);
       
        requirePolicies = new HashSet();
        requirePolicies.add("2.5.29.32.0");
        msg = testPolicies(2, trustCert, intCert, endCert, requirePolicies, true);
        checkMessage(2, msg, "");
  
        /**
         * test_03
         */
        intPolicies = new CertificatePolicies(new PolicyInformation[]
            { new PolicyInformation(new ASN1ObjectIdentifier("2.16.840.1.101.3.2.1.48.3")),
              new PolicyInformation(new ASN1ObjectIdentifier("2.5.29.32.0")) });

        map = new Hashtable();
        map.put("2.16.840.1.101.3.2.1.48.1","2.16.840.1.101.3.2.1.48.2");
        intCert = createIntmedCert(intPubKey, caPrivKey, caPubKey, intPolicies, map);
       
        policies   = new ASN1EncodableVector();
        policies.add(new PolicyInformation(new ASN1ObjectIdentifier("2.16.840.1.101.3.2.1.48.2")));
        endCert = createEndEntityCert(pubKey, intPrivKey, intPubKey, policies);
       
        requirePolicies = new HashSet();
        requirePolicies.add("2.16.840.1.101.3.2.1.48.1");
        msg = testPolicies(3, trustCert, intCert, endCert, requirePolicies, true);
        checkMessage(3, msg, "");
       
        /**
         * test_04
         */
        intPolicies = new CertificatePolicies(new PolicyInformation[]
            { new PolicyInformation(new ASN1ObjectIdentifier("2.16.840.1.101.3.2.1.48.3")),
              new PolicyInformation(new ASN1ObjectIdentifier("2.5.29.32.0")) } );
        map = new Hashtable();
        map.put("2.16.840.1.101.3.2.1.48.1", "2.16.840.1.101.3.2.1.48.2");
        intCert = createIntmedCert(intPubKey, caPrivKey, caPubKey, intPolicies, map);
       
        policies   = new ASN1EncodableVector();
        policies.add(new PolicyInformation(new ASN1ObjectIdentifier("2.16.840.1.101.3.2.1.48.3")));
        endCert = createEndEntityCert(pubKey, intPrivKey, intPubKey, policies);
       
        requirePolicies = new HashSet();
        requirePolicies.add("2.16.840.1.101.3.2.1.48.3");
        msg = testPolicies(4, trustCert, intCert, endCert, requirePolicies, true);
        checkMessage(4, msg, "");
       
        /**
         * test_05
         */
        intPolicies = new CertificatePolicies(new PolicyInformation(new ASN1ObjectIdentifier("2.5.29.32.0")));
        map = new Hashtable();
        map.put("2.16.840.1.101.3.2.1.48.1", "2.16.840.1.101.3.2.1.48.2");
        intCert = createIntmedCert(intPubKey, caPrivKey, caPubKey, intPolicies, map);
       
        policies   = new ASN1EncodableVector();
        policies.add(new PolicyInformation(new ASN1ObjectIdentifier("2.16.840.1.101.3.2.1.48.2")));
        endCert = createEndEntityCert(pubKey, intPrivKey, intPubKey, policies);
       
        requirePolicies = new HashSet();
        requirePolicies.add("2.16.840.1.101.3.2.1.48.2");
        msg = testPolicies(5, trustCert, intCert, endCert, requirePolicies, false);
        checkMessage(5, msg, "Path processing failed on policy.");
       
        /**
         * test_06
         */
        intPolicies = new CertificatePolicies(new PolicyInformation(new ASN1ObjectIdentifier("2.5.29.32.0")));
        map = new Hashtable();
        map.put("2.16.840.1.101.3.2.1.48.1", "2.16.840.1.101.3.2.1.48.2");
        intCert = createIntmedCert(intPubKey, caPrivKey, caPubKey, intPolicies, map);
       
        policies   = new ASN1EncodableVector();
        policies.add(new PolicyInformation(new ASN1ObjectIdentifier("2.16.840.1.101.3.2.1.48.1")));
        endCert = createEndEntityCert(pubKey, intPrivKey, intPubKey, policies);
       
        requirePolicies = new HashSet();
        requirePolicies.add("2.16.840.1.101.3.2.1.48.1");
        msg = testPolicies(6, trustCert, intCert, endCert, requirePolicies, true);
        checkMessage(6, msg, "");
       
        /**
         * test_07
         */
        intPolicies = new CertificatePolicies(new PolicyInformation(new ASN1ObjectIdentifier("2.5.29.32.0")));
        map = new Hashtable();
        map.put("2.16.840.1.101.3.2.1.48.1", "2.16.840.1.101.3.2.1.48.2");
        intCert = createIntmedCert(intPubKey, caPrivKey, caPubKey, intPolicies, map);
       
        policies   = new ASN1EncodableVector();
        policies.add(new PolicyInformation(new ASN1ObjectIdentifier("2.16.840.1.101.3.2.1.48.2")));
        endCert = createEndEntityCert(pubKey, intPrivKey, intPubKey, policies);
       
        requirePolicies = new HashSet();
        requirePolicies.add("2.16.840.1.101.3.2.1.48.3");
        msg = testPolicies(7, trustCert, intCert, endCert, requirePolicies, false);
        checkMessage(7, msg, "Path processing failed on policy.");
       
        /**
         * test_08
         */
        intPolicies = new CertificatePolicies(new PolicyInformation(new ASN1ObjectIdentifier("2.5.29.32.0")));
        map = new Hashtable();
        map.put("2.16.840.1.101.3.2.1.48.1", "2.16.840.1.101.3.2.1.48.2");
        intCert = createIntmedCert(intPubKey, caPrivKey, caPubKey, intPolicies, map);
       
        policies   = new ASN1EncodableVector();
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.