return null;
}
TimeStampTokenInfo timeStampTokenInfo = timeStampToken.getTimeStampInfo();
TimeStamp timeStamp = new TimeStamp();
timeStamp.setDate(timeStampTokenInfo.getGenTime());
timeStamp.setEncoded(timeStampToken.getEncoded());
timeStamp.setHash(timeStampTokenInfo.getMessageImprintDigest());
timeStamp.setNonce(timeStampTokenInfo.getNonce());
timeStamp.setSerialNumber(timeStampTokenInfo.getSerialNumber());
CMSSignedData signedData = timeStampToken.toCMSSignedData();
Object signedContent = signedData.getSignedContent().getContent();
if ((signedContent != null) && (signedContent.getClass().isArray())) {
timeStamp.setContent((byte[]) signedContent);
}
Store certificatesStore = timeStampToken.getCertificates();
Collection certificatesCollection = certificatesStore.getMatches(null);
List<Certificate> certificates = new ArrayList<Certificate>();
for (Object obj : certificatesCollection) {
if (obj instanceof X509CertificateHolder) {
X509CertificateHolder holder = (X509CertificateHolder) obj;
byte[] encoded = holder.getEncoded();
Certificate certificate = SecurityUtils.getCertificateFromFile(encoded, CertificateType.X509);
certificates.add(certificate);
}
}
timeStamp.setCertificates(certificates.toArray(new Certificate[certificates.size()]));
return timeStamp;
}