org.bouncycastle.asn1.x509.CRLReason Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-lts8on Show documentation
Show all versions of bcprov-lts8on Show documentation
The Long Term Stable (LTS) Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains the JCA/JCE provider and low-level API for the BC LTS version 2.73.7 for Java 8 and later.
package org.bouncycastle.asn1.x509;
import java.math.BigInteger;
import java.util.Hashtable;
import org.bouncycastle.asn1.ASN1Enumerated;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.util.Integers;
/**
* The CRLReason enumeration.
*
* CRLReason ::= ENUMERATED {
* unspecified (0),
* keyCompromise (1),
* cACompromise (2),
* affiliationChanged (3),
* superseded (4),
* cessationOfOperation (5),
* certificateHold (6),
* removeFromCRL (8),
* privilegeWithdrawn (9),
* aACompromise (10)
* }
*
*/
public class CRLReason
extends ASN1Object
{
public static final int unspecified = 0;
public static final int keyCompromise = 1;
public static final int cACompromise = 2;
public static final int affiliationChanged = 3;
public static final int superseded = 4;
public static final int cessationOfOperation = 5;
public static final int certificateHold = 6;
// 7 -> unknown
public static final int removeFromCRL = 8;
public static final int privilegeWithdrawn = 9;
public static final int aACompromise = 10;
private static final String[] reasonString =
{
"unspecified", "keyCompromise", "cACompromise", "affiliationChanged",
"superseded", "cessationOfOperation", "certificateHold", "unknown",
"removeFromCRL", "privilegeWithdrawn", "aACompromise"
};
private static final Hashtable table = new Hashtable();
private ASN1Enumerated value;
public static CRLReason getInstance(Object o)
{
if (o instanceof CRLReason)
{
return (CRLReason)o;
}
else if (o != null)
{
return lookup(ASN1Enumerated.getInstance(o).intValueExact());
}
return null;
}
private CRLReason(
int reason)
{
if (reason < 0)
{
throw new IllegalArgumentException("Invalid CRL reason : not in (0..MAX)");
}
value = new ASN1Enumerated(reason);
}
public String toString()
{
String str;
int reason = getValue().intValue();
if (reason < 0 || reason > 10)
{
str = "invalid";
}
else
{
str = reasonString[reason];
}
return "CRLReason: " + str;
}
public BigInteger getValue()
{
return value.getValue();
}
public ASN1Primitive toASN1Primitive()
{
return value;
}
public static CRLReason lookup(int value)
{
Integer idx = Integers.valueOf(value);
if (!table.containsKey(idx))
{
table.put(idx, new CRLReason(value));
}
return (CRLReason)table.get(idx);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy