org.bouncycastle.oer.its.ieee1609dot2.SequenceOfRecipientInfo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcutil-debug-jdk18on Show documentation
Show all versions of bcutil-debug-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.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERSequence;
/**
*
* SequenceOfRecipientInfo ::= SEQUENCE OF RecipientInfo
*
*/
public class SequenceOfRecipientInfo
extends ASN1Object
{
private final List recipientInfos;
public SequenceOfRecipientInfo(List recipientInfos)
{
this.recipientInfos = Collections.unmodifiableList(recipientInfos);
}
private SequenceOfRecipientInfo(ASN1Sequence sequence)
{
ArrayList infoArrayList = new ArrayList();
for (Iterator it = sequence.iterator(); it.hasNext(); )
{
infoArrayList.add(RecipientInfo.getInstance(it.next()));
}
recipientInfos = Collections.unmodifiableList(infoArrayList);
}
public static SequenceOfRecipientInfo getInstance(Object object)
{
if (object instanceof SequenceOfRecipientInfo)
{
return (SequenceOfRecipientInfo)object;
}
if (object != null)
{
return new SequenceOfRecipientInfo(ASN1Sequence.getInstance(object));
}
return null;
}
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
for (RecipientInfo info : recipientInfos)
{
v.add(info);
}
return new DERSequence(v);
}
public List getRecipientInfos()
{
return recipientInfos;
}
public static Builder builder()
{
return new Builder();
}
public static class Builder
{
private List recipientInfos;
public Builder setRecipientInfos(List recipientInfos)
{
this.recipientInfos = recipientInfos;
return this;
}
public Builder addRecipients(RecipientInfo... items)
{
if (recipientInfos == null)
{
recipientInfos = new ArrayList();
}
recipientInfos.addAll(Arrays.asList(items));
return this;
}
public SequenceOfRecipientInfo createSequenceOfRecipientInfo()
{
return new SequenceOfRecipientInfo(recipientInfos);
}
}
}