org.bouncycastle.asn1.test.GetCertTest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-ext-debug-jdk15on Show documentation
Show all versions of bcprov-ext-debug-jdk15on Show documentation
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.5 to JDK 1.8. Note: this package includes the NTRU encryption algorithms.
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);
}
}
}