All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bouncycastle.asn1.cmc.BodyPartID Maven / Gradle / Ivy

Go to download

The Bouncy Castle Java APIs for ASN.1 extension and utility APIs used to support bcpkix and bctls. This jar contains APIs for JDK 1.5 and up.

There is a newer version: 1.70
Show newest version
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