01: package org.bouncycastle.sasn1.cms;
02:
03: import org.bouncycastle.sasn1.Asn1Integer;
04: import org.bouncycastle.sasn1.Asn1Object;
05: import org.bouncycastle.sasn1.Asn1Sequence;
06: import org.bouncycastle.sasn1.Asn1Set;
07: import org.bouncycastle.sasn1.Asn1TaggedObject;
08: import org.bouncycastle.sasn1.BerTag;
09:
10: import java.io.IOException;
11:
12: /**
13: * <pre>
14: * EnvelopedData ::= SEQUENCE {
15: * version CMSVersion,
16: * originatorInfo [0] IMPLICIT OriginatorInfo OPTIONAL,
17: * recipientInfos RecipientInfos,
18: * encryptedContentInfo EncryptedContentInfo,
19: * unprotectedAttrs [1] IMPLICIT UnprotectedAttributes OPTIONAL
20: * }
21: * </pre>
22: * @deprecated use corresponding class in org.bouncycastle.asn1.cms
23: */
24: public class EnvelopedDataParser {
25: private Asn1Sequence _seq;
26: private Asn1Integer _version;
27: private Asn1Object _nextObject;
28:
29: public EnvelopedDataParser(Asn1Sequence seq) throws IOException {
30: this ._seq = seq;
31: this ._version = (Asn1Integer) seq.readObject();
32: }
33:
34: public Asn1Integer getVersion() {
35: return _version;
36: }
37:
38: public Asn1Set getCertificates() throws IOException {
39: _nextObject = _seq.readObject();
40:
41: if (_nextObject instanceof Asn1TaggedObject
42: && ((Asn1TaggedObject) _nextObject).getTagNumber() == 0) {
43: Asn1Set certs = (Asn1Set) ((Asn1TaggedObject) _nextObject)
44: .getObject(BerTag.SET, false);
45: _nextObject = null;
46:
47: return certs;
48: }
49:
50: return null;
51: }
52:
53: public Asn1Set getCrls() throws IOException {
54: if (_nextObject == null) {
55: _nextObject = _seq.readObject();
56: }
57:
58: if (_nextObject instanceof Asn1TaggedObject
59: && ((Asn1TaggedObject) _nextObject).getTagNumber() == 1) {
60: Asn1Set crls = (Asn1Set) ((Asn1TaggedObject) _nextObject)
61: .getObject(BerTag.SET, false);
62: _nextObject = null;
63:
64: return crls;
65: }
66:
67: return null;
68: }
69:
70: public Asn1Set getRecipientInfos() throws IOException {
71: return (Asn1Set) _seq.readObject();
72: }
73:
74: public EncryptedContentInfoParser getEncryptedContentInfo()
75: throws IOException {
76: return new EncryptedContentInfoParser((Asn1Sequence) _seq
77: .readObject());
78: }
79:
80: public Asn1Set getUnprotectedAttrs() throws IOException {
81: Asn1Object o = _seq.readObject();
82:
83: if (o != null) {
84: return (Asn1Set) ((Asn1TaggedObject) o).getObject(
85: BerTag.SET, false);
86: }
87:
88: return null;
89: }
90: }
|