public static TimeStamp toTimeStamp(final TimeStampToken timeStampToken) throws IOException, CertificateException {
if (timeStampToken == null) {
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())) {