org.bouncycastle.asn1.cmc.TaggedContentInfo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-jdk14 Show documentation
Show all versions of bcprov-jdk14 Show documentation
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.4.
package org.bouncycastle.asn1.cmc;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.cms.ContentInfo;
/**
*
* TaggedContentInfo ::= SEQUENCE {
* bodyPartID BodyPartID,
* contentInfo ContentInfo
* }
*
*/
public class TaggedContentInfo
extends ASN1Object
{
private final BodyPartID bodyPartID;
private final ContentInfo contentInfo;
public TaggedContentInfo(BodyPartID bodyPartID, ContentInfo contentInfo)
{
this.bodyPartID = bodyPartID;
this.contentInfo = contentInfo;
}
private TaggedContentInfo(ASN1Sequence seq)
{
if (seq.size() != 2)
{
throw new IllegalArgumentException("incorrect sequence size");
}
this.bodyPartID = BodyPartID.getInstance(seq.getObjectAt(0));
this.contentInfo = ContentInfo.getInstance(seq.getObjectAt(1));
}
public static TaggedContentInfo getInstance(Object o)
{
if (o instanceof TaggedContentInfo)
{
return (TaggedContentInfo)o;
}
if (o != null)
{
return new TaggedContentInfo(ASN1Sequence.getInstance(o));
}
return null;
}
public static TaggedContentInfo getInstance(
ASN1TaggedObject obj,
boolean explicit)
{
return getInstance(ASN1Sequence.getInstance(obj, explicit));
}
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(bodyPartID);
v.add(contentInfo);
return new DERSequence(v);
}
public BodyPartID getBodyPartID()
{
return bodyPartID;
}
public ContentInfo getContentInfo()
{
return contentInfo;
}
}