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

org.bouncycastle.asn1.its.SspRange Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 2.0.3
Show newest version
package org.bouncycastle.asn1.its;

import java.io.IOException;

import org.bouncycastle.asn1.ASN1Null;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERNull;

/**
 * 
 * SspRange ::= CHOICE {
 *     opaque SequenceOfOctetString,
 *     all NULL,
 *     ...
 *     bitmapSspRange BitmapSspRange
 * }
 * 
*/ public class SspRange extends ASN1Object { private final boolean isAll; private final SequenceOfOctetString opaque; private final BitmapSspRange bitmapSspRange; private SspRange() { isAll = true; opaque = null; bitmapSspRange = null; } private SspRange(SequenceOfOctetString seq) { this.isAll = false; if (seq.size() != 2) { opaque = seq; bitmapSspRange = null; } else { // ambiguous opaque = SequenceOfOctetString.getInstance(seq); BitmapSspRange bitMapRange; try { bitMapRange = BitmapSspRange.getInstance(seq); } catch (IllegalArgumentException e) { bitMapRange = null; } bitmapSspRange = bitMapRange; } } public SspRange(BitmapSspRange range) { this.isAll = false; this.bitmapSspRange = range; this.opaque = null; } public static SspRange getInstance(Object src) { if (src == null) { return null; } if (src instanceof SspRange) { return (SspRange)src; } if (src instanceof ASN1Null) { return new SspRange(); } if (src instanceof ASN1Sequence) { return new SspRange(SequenceOfOctetString.getInstance(src)); } if (src instanceof byte[]) { try { return getInstance(ASN1Primitive.fromByteArray((byte[])src)); } catch (IOException e) { throw new IllegalArgumentException("unable to parse encoded general name"); } } throw new IllegalArgumentException("unknown object in getInstance: " + src.getClass().getName()); } public boolean isAll() { return isAll; } public boolean maybeOpaque() { return opaque != null; } public BitmapSspRange getBitmapSspRange() { return bitmapSspRange; } public SequenceOfOctetString getOpaque() { return opaque; } public ASN1Primitive toASN1Primitive() { if (isAll) { return DERNull.INSTANCE; } if (bitmapSspRange != null) { return bitmapSspRange.toASN1Primitive(); } return opaque.toASN1Primitive(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy