com.fitbur.bouncycastle.asn1.test.KeyUsageTest Maven / Gradle / Ivy
package com.fitbur.bouncycastle.asn1.test;
import java.io.IOException;
import com.fitbur.bouncycastle.asn1.x509.KeyUsage;
import com.fitbur.bouncycastle.util.test.SimpleTest;
public class KeyUsageTest
extends SimpleTest
{
public String getName()
{
return "KeyUsage";
}
public void performTest()
throws IOException
{
BitStringConstantTester.testFlagValueCorrect(0, KeyUsage.digitalSignature);
BitStringConstantTester.testFlagValueCorrect(1, KeyUsage.nonRepudiation);
BitStringConstantTester.testFlagValueCorrect(2, KeyUsage.keyEncipherment);
BitStringConstantTester.testFlagValueCorrect(3, KeyUsage.dataEncipherment);
BitStringConstantTester.testFlagValueCorrect(4, KeyUsage.keyAgreement);
BitStringConstantTester.testFlagValueCorrect(5, KeyUsage.keyCertSign);
BitStringConstantTester.testFlagValueCorrect(6, KeyUsage.cRLSign);
BitStringConstantTester.testFlagValueCorrect(7, KeyUsage.encipherOnly);
BitStringConstantTester.testFlagValueCorrect(8, KeyUsage.com.fitburcipherOnly);
if (!new KeyUsage(KeyUsage.keyCertSign).hasUsages(KeyUsage.keyCertSign))
{
fail("usages bit test failed 1");
}
if (new KeyUsage(KeyUsage.cRLSign).hasUsages(KeyUsage.keyCertSign))
{
fail("usages bit test failed 2");
}
if (!new KeyUsage(KeyUsage.cRLSign | KeyUsage.com.fitburcipherOnly).hasUsages(KeyUsage.cRLSign | KeyUsage.com.fitburcipherOnly))
{
fail("usages bit test failed 3");
}
if (new KeyUsage(KeyUsage.cRLSign | KeyUsage.com.fitburcipherOnly).hasUsages(KeyUsage.cRLSign | KeyUsage.com.fitburcipherOnly | KeyUsage.keyCertSign))
{
fail("usages bit test failed 4");
}
}
public static void main(
String[] args)
{
runTest(new KeyUsageTest());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy