01: package org.bouncycastle.asn1.esf;
02:
03: import org.bouncycastle.asn1.ASN1EncodableVector;
04: import org.bouncycastle.asn1.ASN1Sequence;
05: import org.bouncycastle.asn1.ASN1Encodable;
06: import org.bouncycastle.asn1.DERObject;
07: import org.bouncycastle.asn1.DERObjectIdentifier;
08: import org.bouncycastle.asn1.DERSequence;
09:
10: public class CommitmentTypeIndication extends ASN1Encodable {
11: private DERObjectIdentifier commitmentTypeId;
12: private ASN1Sequence commitmentTypeQualifier;
13:
14: public CommitmentTypeIndication(ASN1Sequence seq) {
15: commitmentTypeId = (DERObjectIdentifier) seq.getObjectAt(0);
16:
17: if (seq.size() > 1) {
18: commitmentTypeQualifier = (ASN1Sequence) seq.getObjectAt(1);
19: }
20: }
21:
22: public CommitmentTypeIndication(DERObjectIdentifier commitmentTypeId) {
23: this .commitmentTypeId = commitmentTypeId;
24: }
25:
26: public CommitmentTypeIndication(
27: DERObjectIdentifier commitmentTypeId,
28: ASN1Sequence commitmentTypeQualifier) {
29: this .commitmentTypeId = commitmentTypeId;
30: this .commitmentTypeQualifier = commitmentTypeQualifier;
31: }
32:
33: public static CommitmentTypeIndication getInstance(Object obj) {
34: if (obj == null || obj instanceof CommitmentTypeIndication) {
35: return (CommitmentTypeIndication) obj;
36: }
37:
38: return new CommitmentTypeIndication(ASN1Sequence
39: .getInstance(obj));
40: }
41:
42: public DERObjectIdentifier getCommitmentTypeId() {
43: return commitmentTypeId;
44: }
45:
46: public ASN1Sequence getCommitmentTypeQualifier() {
47: return commitmentTypeQualifier;
48: }
49:
50: /**
51: * <pre>
52: * CommitmentTypeIndication ::= SEQUENCE {
53: * commitmentTypeId CommitmentTypeIdentifier,
54: * commitmentTypeQualifier SEQUENCE SIZE (1..MAX) OF
55: * CommitmentTypeQualifier OPTIONAL }
56: * </pre>
57: */
58: public DERObject toASN1Object() {
59: ASN1EncodableVector v = new ASN1EncodableVector();
60:
61: v.add(commitmentTypeId);
62:
63: if (commitmentTypeQualifier != null) {
64: v.add(commitmentTypeQualifier);
65: }
66:
67: return new DERSequence(v);
68: }
69: }
|