1/* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 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 20package org.apache.harmony.security.x509.tsp; 21 22import org.apache.harmony.security.asn1.ASN1Sequence; 23import org.apache.harmony.security.asn1.ASN1Type; 24import org.apache.harmony.security.asn1.BerInputStream; 25import 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 */ 37public class TimeStampResp { 38 39 private final PKIStatusInfo status; 40 41 private final ContentInfo timeStampToken; 42 43 public TimeStampResp(PKIStatusInfo status, ContentInfo timeStampToken) { 44 this.status = status; 45 this.timeStampToken = timeStampToken; 46 } 47 48 public String toString(){ 49 StringBuilder res = new StringBuilder(); 50 res.append("-- TimeStampResp:"); 51 res.append("\nstatus: "); 52 res.append(status); 53 res.append("\ntimeStampToken: "); 54 res.append(timeStampToken); 55 res.append("\n-- TimeStampResp End\n"); 56 return res.toString(); 57 } 58 59 /** 60 * @return Returns the status. 61 */ 62 public PKIStatusInfo getStatus() { 63 return status; 64 } 65 66 /** 67 * @return Returns the timeStampToken. 68 */ 69 public ContentInfo getTimeStampToken() { 70 return timeStampToken; 71 } 72 73 public static final ASN1Sequence ASN1 = new ASN1Sequence(new ASN1Type[] { 74 PKIStatusInfo.ASN1, // status 75 ContentInfo.ASN1}) { // timeStampToken 76 77 { 78 setOptional(1); 79 } 80 81 protected Object getDecodedObject(BerInputStream in) { 82 Object[] values = (Object[]) in.content; 83 return new TimeStampResp( 84 (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} 96 97