01: package org.bouncycastle.asn1.ocsp;
02:
03: import org.bouncycastle.asn1.ASN1EncodableVector;
04: import org.bouncycastle.asn1.ASN1OctetString;
05: import org.bouncycastle.asn1.ASN1Sequence;
06: import org.bouncycastle.asn1.ASN1TaggedObject;
07: import org.bouncycastle.asn1.ASN1Encodable;
08: import org.bouncycastle.asn1.DERObject;
09: import org.bouncycastle.asn1.DERObjectIdentifier;
10: import org.bouncycastle.asn1.DERSequence;
11:
12: public class ResponseBytes extends ASN1Encodable {
13: DERObjectIdentifier responseType;
14: ASN1OctetString response;
15:
16: public ResponseBytes(DERObjectIdentifier responseType,
17: ASN1OctetString response) {
18: this .responseType = responseType;
19: this .response = response;
20: }
21:
22: public ResponseBytes(ASN1Sequence seq) {
23: responseType = (DERObjectIdentifier) seq.getObjectAt(0);
24: response = (ASN1OctetString) seq.getObjectAt(1);
25: }
26:
27: public static ResponseBytes getInstance(ASN1TaggedObject obj,
28: boolean explicit) {
29: return getInstance(ASN1Sequence.getInstance(obj, explicit));
30: }
31:
32: public static ResponseBytes getInstance(Object obj) {
33: if (obj == null || obj instanceof ResponseBytes) {
34: return (ResponseBytes) obj;
35: } else if (obj instanceof ASN1Sequence) {
36: return new ResponseBytes((ASN1Sequence) obj);
37: }
38:
39: throw new IllegalArgumentException("unknown object in factory");
40: }
41:
42: public DERObjectIdentifier getResponseType() {
43: return responseType;
44: }
45:
46: public ASN1OctetString getResponse() {
47: return response;
48: }
49:
50: /**
51: * Produce an object suitable for an ASN1OutputStream.
52: * <pre>
53: * ResponseBytes ::= SEQUENCE {
54: * responseType OBJECT IDENTIFIER,
55: * response OCTET STRING }
56: * </pre>
57: */
58: public DERObject toASN1Object() {
59: ASN1EncodableVector v = new ASN1EncodableVector();
60:
61: v.add(responseType);
62: v.add(response);
63:
64: return new DERSequence(v);
65: }
66: }
|