SignerInfo sigInfo = new SignerInfo(1, issuerAndSerialNumber,
new AlgorithmIdentifier(sha1), null, new AlgorithmIdentifier(
sha1dsa), new byte[20], null);
// TSTInfo OID according to RFC 3161
int[] tSTInfoOid = new int[] { 1, 2, 840, 113549, 1, 9, 16, 1, 4 };
ContentInfo tSTInfoEncoded = new ContentInfo(tSTInfoOid,
ASN1OctetString.getInstance().encode(
TSTInfo.ASN1.encode(tSTInfo)));
SignedData tokenContent = new SignedData(1, Collections
.singletonList(new AlgorithmIdentifier(sha1)), tSTInfoEncoded,
null, null, Collections.singletonList(sigInfo));
ContentInfo timeStampToken = new ContentInfo(ContentInfo.SIGNED_DATA,
tokenContent);
TimeStampResp response = new TimeStampResp(status, timeStampToken);
byte [] encoding = TimeStampResp.ASN1.encode(response);
TimeStampResp decoded = (TimeStampResp) TimeStampResp.ASN1
.decode(encoding);
// deeper checks are performed in the corresponding unit tests
assertTrue("Decoded status is incorrect", Arrays.equals(
PKIStatusInfo.ASN1.encode(status), PKIStatusInfo.ASN1
.encode(decoded.getStatus())));
assertTrue("Decoded timeStampToken is incorrect", Arrays.equals(
timeStampToken.getEncoded(), decoded.getTimeStampToken()
.getEncoded()));
}