01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19:
20: package org.apache.harmony.security.x509.tsp;
21:
22: import org.apache.harmony.security.asn1.ASN1Sequence;
23: import org.apache.harmony.security.asn1.ASN1Type;
24: import org.apache.harmony.security.asn1.BerInputStream;
25: import org.apache.harmony.security.pkcs7.ContentInfo;
26:
27: /**
28: * As defined in Time-Stamp Protocol (TSP)
29: * (http://www.ietf.org/rfc/rfc3161.txt)
30: *
31: * TimeStampResp ::= SEQUENCE {
32: * status PKIStatusInfo,
33: * timeStampToken TimeStampToken OPTIONAL
34: * }
35: *
36: */
37: public class TimeStampResp {
38:
39: private final PKIStatusInfo status;
40:
41: private final ContentInfo timeStampToken;
42:
43: public TimeStampResp(PKIStatusInfo status,
44: ContentInfo timeStampToken) {
45: this .status = status;
46: this .timeStampToken = timeStampToken;
47: }
48:
49: public String toString() {
50: StringBuffer res = new StringBuffer();
51: res.append("-- TimeStampResp:");
52: res.append("\nstatus: ");
53: res.append(status);
54: res.append("\ntimeStampToken: ");
55: res.append(timeStampToken);
56: res.append("\n-- TimeStampResp End\n");
57: return res.toString();
58: }
59:
60: /**
61: * @return Returns the status.
62: */
63: public PKIStatusInfo getStatus() {
64: return status;
65: }
66:
67: /**
68: * @return Returns the timeStampToken.
69: */
70: public ContentInfo getTimeStampToken() {
71: return timeStampToken;
72: }
73:
74: public static final ASN1Sequence ASN1 = new ASN1Sequence(
75: new ASN1Type[] { PKIStatusInfo.ASN1, // status
76: ContentInfo.ASN1 }) { // timeStampToken
77:
78: {
79: setOptional(1);
80: }
81:
82: protected Object getDecodedObject(BerInputStream in) {
83: Object[] values = (Object[]) in.content;
84: return new TimeStampResp((PKIStatusInfo) values[0],
85: (ContentInfo) values[1]);
86: }
87:
88: protected void getValues(Object object, Object[] values) {
89: TimeStampResp resp = (TimeStampResp) object;
90:
91: values[0] = resp.status;
92: values[1] = resp.timeStampToken;
93: }
94: };
95: }
|