org.bouncycastle.oer.its.ieee1609dot2.ContributedExtensionBlocks 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.
package org.bouncycastle.oer.its.ieee1609dot2;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERSequence;
public class ContributedExtensionBlocks
extends ASN1Object
{
private final List contributedExtensionBlocks;
public ContributedExtensionBlocks(List extensionBlocks)
{
this.contributedExtensionBlocks = Collections.unmodifiableList(extensionBlocks);
}
private ContributedExtensionBlocks(ASN1Sequence sequence)
{
List blocks = new ArrayList();
for (Iterator it = sequence.iterator(); it.hasNext(); )
{
blocks.add(ContributedExtensionBlock.getInstance(it.next()));
}
contributedExtensionBlocks = Collections.unmodifiableList(blocks);
}
public static Builder builder()
{
return new Builder();
}
public List getContributedExtensionBlocks()
{
return contributedExtensionBlocks;
}
public int size()
{
return contributedExtensionBlocks.size();
}
public static ContributedExtensionBlocks getInstance(Object o)
{
if (o instanceof ContributedExtensionBlocks)
{
return (ContributedExtensionBlocks)o;
}
if (o != null)
{
return new ContributedExtensionBlocks(ASN1Sequence.getInstance(o));
}
return null;
}
@Override
public ASN1Primitive toASN1Primitive()
{
return new DERSequence(contributedExtensionBlocks.toArray(new ContributedExtensionBlock[0]));
}
public static class Builder
{
private final List extensionBlocks = new ArrayList();
public Builder add(ContributedExtensionBlock... blocks)
{
extensionBlocks.addAll(Arrays.asList(blocks));
return this;
}
public ContributedExtensionBlocks build()
{
return new ContributedExtensionBlocks(extensionBlocks);
}
}
}