01: package org.bouncycastle.asn1.x509.qualified;
02:
03: import java.util.Enumeration;
04:
05: import org.bouncycastle.asn1.ASN1Encodable;
06: import org.bouncycastle.asn1.ASN1Sequence;
07: import org.bouncycastle.asn1.ASN1EncodableVector;
08: import org.bouncycastle.asn1.DERObject;
09: import org.bouncycastle.asn1.DERObjectIdentifier;
10: import org.bouncycastle.asn1.DERSequence;
11:
12: /**
13: * The QCStatement object.
14: * <pre>
15: * QCStatement ::= SEQUENCE {
16: * statementId OBJECT IDENTIFIER,
17: * statementInfo ANY DEFINED BY statementId OPTIONAL}
18: * </pre>
19: */
20:
21: public class QCStatement extends ASN1Encodable implements
22: ETSIQCObjectIdentifiers, RFC3739QCObjectIdentifiers {
23: DERObjectIdentifier qcStatementId;
24: ASN1Encodable qcStatementInfo;
25:
26: public static QCStatement getInstance(Object obj) {
27: if (obj == null || obj instanceof QCStatement) {
28: return (QCStatement) obj;
29: }
30:
31: if (obj instanceof ASN1Sequence) {
32: return new QCStatement(ASN1Sequence.getInstance(obj));
33: }
34:
35: throw new IllegalArgumentException(
36: "unknown object in getInstance");
37: }
38:
39: public QCStatement(ASN1Sequence seq) {
40: Enumeration e = seq.getObjects();
41:
42: // qcStatementId
43: qcStatementId = DERObjectIdentifier
44: .getInstance(e.nextElement());
45: // qcstatementInfo
46: if (e.hasMoreElements()) {
47: qcStatementInfo = (ASN1Encodable) e.nextElement();
48: }
49: }
50:
51: public QCStatement(DERObjectIdentifier qcStatementId) {
52: this .qcStatementId = qcStatementId;
53: this .qcStatementInfo = null;
54: }
55:
56: public QCStatement(DERObjectIdentifier qcStatementId,
57: ASN1Encodable qcStatementInfo) {
58: this .qcStatementId = qcStatementId;
59: this .qcStatementInfo = qcStatementInfo;
60: }
61:
62: public DERObjectIdentifier getStatementId() {
63: return qcStatementId;
64: }
65:
66: public ASN1Encodable getStatementInfo() {
67: return qcStatementInfo;
68: }
69:
70: public DERObject toASN1Object() {
71: ASN1EncodableVector seq = new ASN1EncodableVector();
72: seq.add(qcStatementId);
73:
74: if (qcStatementInfo != null) {
75: seq.add(qcStatementInfo);
76: }
77:
78: return new DERSequence(seq);
79: }
80: }
|