* parsing the timestamp response.
*/
private void parse(byte[] tsReply) throws IOException {
// Decode TimeStampResp
DerValue derValue = new DerValue(tsReply);
if (derValue.tag != DerValue.tag_Sequence) {
throw new IOException("Bad encoding for timestamp response");
}
// Parse status
DerValue status = derValue.data.getDerValue();
// Parse status
this.status = status.data.getInteger();
if (DEBUG) {
System.out.println("timestamp response: status=" + this.status);
}
// Parse statusString, if present
if (status.data.available() > 0) {
DerValue[] strings = status.data.getSequence(1);
statusString = new String[strings.length];
for (int i = 0; i < strings.length; i++) {
statusString[i] = strings[i].data.getUTF8String();
}
}
// Parse failInfo, if present
if (status.data.available() > 0) {
byte[] failInfo = status.data.getBitString();
int failureInfo = (new Byte(failInfo[0])).intValue();
if (failureInfo < 0 || failureInfo > 25 || failInfo.length != 1) {
throw new IOException("Bad encoding for timestamp response: " +
"unrecognized value for the failInfo element");
}
this.failureInfo = failureInfo;
}
// Parse timeStampToken, if present
if (derValue.data.available() > 0) {
DerValue timestampToken = derValue.data.getDerValue();
encodedTsToken = timestampToken.toByteArray();
tsToken = new PKCS7(encodedTsToken);
}
// Check the format of the timestamp response
if (this.status == 0 || this.status == 1) {