org.bouncycastle.oer.its.ieee1609dot2.ContributedExtensionBlock Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcutil-jdk18on Show documentation
Show all versions of bcutil-jdk18on Show documentation
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.8 and up.
package org.bouncycastle.oer.its.ieee1609dot2;
import java.util.ArrayList;
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.oer.its.ItsUtils;
import org.bouncycastle.oer.its.etsi103097.extension.EtsiOriginatingHeaderInfoExtension;
/**
* ContributedExtensionBlock ::= SEQUENCE {
* contributorId IEEE1609DOT2-HEADERINFO-CONTRIBUTED-EXTENSION.
* &id({Ieee1609Dot2HeaderInfoContributedExtensions}),
* extns SEQUENCE (SIZE(1..MAX)) OF IEEE1609DOT2-HEADERINFO-CONTRIBUTED-EXTENSION.
* &Extn({Ieee1609Dot2HeaderInfoContributedExtensions}{@.contributorId})
* }
*/
public class ContributedExtensionBlock
extends ASN1Object
{
private final HeaderInfoContributorId contributorId;
private final List extns;
public ContributedExtensionBlock(HeaderInfoContributorId contributorId, List extns)
{
this.contributorId = contributorId;
this.extns = extns;
}
private ContributedExtensionBlock(ASN1Sequence sequence)
{
if (sequence.size() != 2)
{
throw new IllegalArgumentException("expected sequence size of 2");
}
contributorId = HeaderInfoContributorId.getInstance(sequence.getObjectAt(0));
Iterator items = ASN1Sequence.getInstance(sequence.getObjectAt(1)).iterator();
List extns = new ArrayList();
while (items.hasNext())
{
extns.add(EtsiOriginatingHeaderInfoExtension.getInstance(items.next()));
}
this.extns = Collections.unmodifiableList(extns);
}
public static ContributedExtensionBlock getInstance(Object src)
{
if (src instanceof ContributedExtensionBlock)
{
return (ContributedExtensionBlock)src;
}
if (src != null)
{
return new ContributedExtensionBlock(ASN1Sequence.getInstance(src));
}
return null;
}
public ASN1Primitive toASN1Primitive()
{
return ItsUtils.toSequence(contributorId, ItsUtils.toSequence(extns));
}
public HeaderInfoContributorId getContributorId()
{
return contributorId;
}
public List getExtns()
{
return extns;
}
}