org.bouncycastle.asn1.cmc.BodyPartID 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 with debug enabled.
package org.bouncycastle.asn1.cmc;
import java.math.BigInteger;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Primitive;
/**
*
* bodyIdMax INTEGER ::= 4294967295
*
* BodyPartID ::= INTEGER(0..bodyIdMax)
*
*/
public class BodyPartID
extends ASN1Object
{
public static final long bodyIdMax = 4294967295L;
private final long id;
public BodyPartID(long id)
{
if (id < 0 || id > bodyIdMax)
{
throw new IllegalArgumentException("id out of range");
}
this.id = id;
}
private static long convert(BigInteger value)
{
if (value.bitLength() > 32)
{
throw new IllegalArgumentException("id out of range");
}
return value.longValue();
}
private BodyPartID(ASN1Integer id)
{
this(convert(id.getValue()));
}
public static BodyPartID getInstance(Object o)
{
if (o instanceof BodyPartID)
{
return (BodyPartID)o;
}
if (o != null)
{
return new BodyPartID(ASN1Integer.getInstance(o));
}
return null;
}
public long getID()
{
return id;
}
public ASN1Primitive toASN1Primitive()
{
return new ASN1Integer(id);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy