01: package org.bouncycastle.asn1.cms;
02:
03: import org.bouncycastle.asn1.DERObjectIdentifier;
04: import org.bouncycastle.asn1.ASN1SequenceParser;
05: import org.bouncycastle.asn1.DEREncodable;
06: import org.bouncycastle.asn1.ASN1TaggedObjectParser;
07:
08: import java.io.IOException;
09:
10: /**
11: * Produce an object suitable for an ASN1OutputStream.
12: * <pre>
13: * ContentInfo ::= SEQUENCE {
14: * contentType ContentType,
15: * content
16: * [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL }
17: * </pre>
18: */
19: public class ContentInfoParser {
20: private DERObjectIdentifier contentType;
21: private ASN1TaggedObjectParser content;
22:
23: public ContentInfoParser(ASN1SequenceParser seq) throws IOException {
24: contentType = (DERObjectIdentifier) seq.readObject();
25: content = (ASN1TaggedObjectParser) seq.readObject();
26: }
27:
28: public DERObjectIdentifier getContentType() {
29: return contentType;
30: }
31:
32: public DEREncodable getContent(int tag) throws IOException {
33: if (content != null) {
34: return content.getObjectParser(tag, true);
35: }
36:
37: return null;
38: }
39: }
|