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

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


            new Certificate(tbsCertificate, signature, signatureValue);

        certEncoding = cert.getEncoded();

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


    }

    public void testCreation() {
        try {
            ByteArrayInputStream bis = new ByteArrayInputStream(certEncoding);
            certificate = new X509CertImpl(bis);
        } catch (Exception e) {
            fail("Creation of a certificate from a stream failed.");
        }
    }
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

            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

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.