Package org.apache.harmony.security.provider.cert

Examples of org.apache.harmony.security.provider.cert.X509CertImpl


        // actual X.509 certificate generation
        org.apache.harmony.security.x509.Certificate cert;
        cert = new org.apache.harmony.security.x509.Certificate(tbsCertificate,
                algId, signatureValue);
        return new X509CertImpl(cert);
    }
View Full Code Here


            return null;
        }
        X509Certificate[] certs = new X509Certificate[encCerts.size()];
        int i = 0;
        for (Iterator it = encCerts.iterator(); it.hasNext();) {
            certs[i++]= new X509CertImpl((org.apache.harmony.security.x509.Certificate)it.next());
        }

        List sigInfos = signedData.getSignerInfos();
        SignerInfo sigInfo;
        if (!sigInfos.isEmpty()) {
View Full Code Here

            new Certificate(tbsCertificate, signature, signatureValue);

        certEncoding = cert.getEncoded();

        cert = (Certificate) Certificate.ASN1.decode(certEncoding);
        certificate = new X509CertImpl(cert);
    }
View Full Code Here

        certificate = new X509CertImpl(cert);
    }

    public void testCreation() throws Exception {
        ByteArrayInputStream bis = new ByteArrayInputStream(certEncoding);
        certificate = new X509CertImpl(bis);
    }
View Full Code Here

    public void testGetVersion() throws IOException {

        byte[] x509CertEnc = TestUtils.getX509Certificate_v1();

        // test initial version that is 1
        assertEquals("Version 1:", 1, new X509CertImpl(x509CertEnc)
                .getVersion());

        // as fas as we know offset of version byte in the cert. encoding
        // it is possible to change it to test other versions

        // offset of version byte in certificate encoding
        int offset = 8;

        // set version to 2
        x509CertEnc[offset] = 1;
        assertEquals("Version 2:", 2, new X509CertImpl(x509CertEnc)
                .getVersion());

        // set version to 3
        x509CertEnc[offset] = 2;
        assertEquals("Version 3:", 3, new X509CertImpl(x509CertEnc)
                .getVersion());
    }
View Full Code Here

    /**
     * getRevokedCertificate(X509Certificate certificate) method testing.
     */
    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),
View Full Code Here

    /**
     * isRevoked(Certificate cert) method testing.
     */
    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),
View Full Code Here

        String sigProvider = (param.getSigProvider() != null) ? param
                .getSigProvider() : provider;

        if (selfSigned) {
            // generate the certificate
            X509CertImpl x509cert = genX509CertImpl(sigAlgName, version,
                    serialNr, subjectDN, subjectDN, validity, keyPair
                            .getPublic(), privateKey, sigProvider,
                    param.isCA());

            // put the key pair with the newly created cert into the keystore
            keyStore.setKeyEntry(param.getAlias(), privateKey, param
                    .getKeyPass(), new X509Certificate[] { x509cert });

        } else {
            // generate the certificate
            X509CertImpl x509cert = genX509CertImpl(sigAlgName, version,
                    serialNr, subjectDN, issuerDN, validity, keyPair
                            .getPublic(), issuerPrivateKey,
                    sigProvider, param.isCA());

            // construct the certificate chain
View Full Code Here

                .valueOf(randomInt);

        // generate a new certificate
        String sigProvider = (param.getSigProvider() != null) ? param
                .getSigProvider() : param.getProvider();
        X509CertImpl x509cert = genX509CertImpl(sigAlgName, version, serialNr,
                distinguishedName, distinguishedName, validity, existing
                        .getPublicKey(), privateKey, sigProvider, param.isCA());

        if (param.isVerbose()) {
            System.out.println("New self-signed certificate: ");
            System.out.println("Version: v" + x509cert.getVersion());
            System.out.println("Owner: " + x509cert.getSubjectX500Principal());
            System.out.println("Issuer: " + x509cert.getIssuerX500Principal());
            System.out.println("Public key: " + x509cert.getPublicKey());
            System.out
                    .println("Signature algorithm: OID."
                            + x509cert.getSigAlgOID() + ", "
                            + x509cert.getSigAlgName());
            System.out
                    .println("Serial number: "
                            // String.format("%x", x509cert.getSerialNumber()));
                            // TODO: print with String.format(..) when the
                            // method is
                            // implemented, and remove Integer.toHexString(..).
                            + Integer.toHexString(x509cert.getSerialNumber()
                                    .intValue()));

            System.out.println("Validity: \n    From: "
                    + x509cert.getNotBefore() + "\n      To: "
                    + x509cert.getNotAfter());
        }

        // put the new certificate into the entry, associated with the alias
        keyStore.setKeyEntry(alias, privateKey, param.getKeyPass(),
                new X509Certificate[] { x509cert });
View Full Code Here

        // actual X.509 certificate generation
        org.apache.harmony.security.x509.Certificate cert;
        cert = new org.apache.harmony.security.x509.Certificate(tbsCertificate,
                algId, signatureValue);
        return new X509CertImpl(cert);
    }
View Full Code Here

TOP

Related Classes of org.apache.harmony.security.provider.cert.X509CertImpl

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.