org.bouncycastle.oer.its.etsi103097.extension.ExtId Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcutil-fips Show documentation
Show all versions of bcutil-fips Show documentation
The Bouncy Castle Java APIs for ASN.1 extension and utility APIs used to support bcpkix and bctls with the BC FIPS provider. The APIs may also be used with other providers although if being used in a FIPS context it is the responsibility of the user to ensure that any other providers used are FIPS certified and used appropriately.
The newest version!
package org.bouncycastle.oer.its.etsi103097.extension;
import java.math.BigInteger;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Primitive;
/**
* ExtId ::= INTEGER(0..255)
*/
public class ExtId
extends ASN1Object
{
private final BigInteger extId;
private static final BigInteger MAX = BigInteger.valueOf(255);
public ExtId(long value)
{
this(BigInteger.valueOf(value));
}
public ExtId(BigInteger value)
{
if (value.signum() < 0 || value.compareTo(MAX) > 0)
{
throw new IllegalArgumentException("value " + value + " outside of range 0...255");
}
this.extId = value;
}
public ExtId(byte[] bytes)
{
this(new BigInteger(bytes));
}
private ExtId(ASN1Integer integer)
{
this(integer.getValue());
}
public BigInteger getExtId()
{
return extId;
}
public static ExtId getInstance(Object object)
{
if (object instanceof ExtId)
{
return (ExtId)object;
}
if (object != null)
{
return new ExtId(ASN1Integer.getInstance(object));
}
return null;
}
public ASN1Primitive toASN1Primitive()
{
return new ASN1Integer(extId);
}
}