All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bouncycastle.asn1.test.GetCertTest Maven / Gradle / Ivy

Go to download

The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.4.

There is a newer version: 1.79
Show newest version
package org.bouncycastle.asn1.test;

import java.math.BigInteger;

import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.cmc.GetCert;
import org.bouncycastle.asn1.x509.GeneralName;
import org.bouncycastle.util.test.SimpleTest;


public class GetCertTest extends SimpleTest
{
    public static void main(String[] args) {
        runTest(new GetCertTest());
    }

    public String getName()
    {
        return "GetCertTest";
    }

    public void performTest()
        throws Exception
    {
        GetCert gs = new GetCert(new GeneralName(GeneralName.dNSName,"fish"),new BigInteger("109"));
        byte[] b = gs.getEncoded();
        GetCert gsResp = GetCert.getInstance(b);

        isEquals("Issuer Name",gs.getIssuerName(), gsResp.getIssuerName());
        isEquals("Serial Number",gs.getSerialNumber(), gsResp.getSerialNumber());

        try {
            GetCert.getInstance(new DERSequence(new ASN1Integer(1L)));
            fail("Sequence must be length of 2");
        } catch (Throwable t) {
            isEquals("Wrong exception",t.getClass(), IllegalArgumentException.class);
        }

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy