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

com.distrimind.bouncycastle.oer.its.ieee1609dot2.SequenceOfRecipientInfo Maven / Gradle / Ivy

package com.distrimind.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 com.distrimind.bouncycastle.asn1.ASN1Encodable;
import com.distrimind.bouncycastle.asn1.ASN1EncodableVector;
import com.distrimind.bouncycastle.asn1.ASN1Object;
import com.distrimind.bouncycastle.asn1.ASN1Primitive;
import com.distrimind.bouncycastle.asn1.ASN1Sequence;
import com.distrimind.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); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy