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

org.bouncycastle.oer.its.SequenceOfRecipientInfo Maven / Gradle / Ivy

Go to download

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.5 and up.

The newest version!
package org.bouncycastle.oer.its;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;

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); } public static SequenceOfRecipientInfo getInstance(Object object) { if (object instanceof SequenceOfRecipientInfo) { return (SequenceOfRecipientInfo)object; } ASN1Sequence sequence = ASN1Sequence.getInstance(object); Enumeration enumeration = sequence.getObjects(); ArrayList infoArrayList = new ArrayList(); while (enumeration.hasMoreElements()) { infoArrayList.add(RecipientInfo.getInstance(enumeration.nextElement())); } return new Builder().setRecipientInfos(infoArrayList).createSequenceOfRecipientInfo(); } public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(); return new DERSequence(v); } public List getRecipientInfos() { return recipientInfos; } 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