org.bouncycastle.asn1.test.PublishTrustAnchorsTest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-jdk14 Show documentation
Show all versions of bcprov-jdk14 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.4.
package org.bouncycastle.asn1.test;
import java.math.BigInteger;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.cmc.PublishTrustAnchors;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.util.test.SimpleTest;
public class PublishTrustAnchorsTest
extends SimpleTest
{
public static void main(String[] args)
{
runTest(new PublishTrustAnchorsTest());
}
public String getName()
{
return "PublishTrustAnchorsTest";
}
public void performTest()
throws Exception
{
PublishTrustAnchors publishTrustAnchors = new PublishTrustAnchors(
new BigInteger("10"), new AlgorithmIdentifier(PKCSObjectIdentifiers.crlTypes,
new ASN1Integer(5L)), new byte[][]{"cats".getBytes()});
byte[] b = publishTrustAnchors.getEncoded();
PublishTrustAnchors publishTrustAnchorsResult = PublishTrustAnchors.getInstance(b);
isEquals("seqNumber", publishTrustAnchors.getSeqNumber(), publishTrustAnchorsResult.getSeqNumber());
isEquals("hashAlgorithm", publishTrustAnchors.getHashAlgorithm(), publishTrustAnchorsResult.getHashAlgorithm());
isTrue("anchorHashes", areEqual(publishTrustAnchors.getAnchorHashes(), publishTrustAnchorsResult.getAnchorHashes()));
try
{
PublishTrustAnchors.getInstance(new DERSequence());
fail("Sequence must be 3");
}
catch (Throwable t)
{
isEquals("Expect IllegalArgumentException", t.getClass(), IllegalArgumentException.class);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy