private void initialize(ContentInfo contentInfo) { this.contentInfo = contentInfo; if (CMSObjectIdentifiers.timestampedData.equals(contentInfo.getContentType())) { this.timeStampedData = TimeStampedData.getInstance(contentInfo.getContent()); } else { throw new IllegalArgumentException("Malformed content - type must be " + CMSObjectIdentifiers.timestampedData.getId()); } util = new TimeStampDataUtil(this.timeStampedData); }
/** * Return a new timeStampedData object with the additional token attached. * * @throws CMSException */ public CMSTimeStampedData addTimeStamp(TimeStampToken token) throws CMSException { TimeStampAndCRL[] timeStamps = util.getTimeStamps(); TimeStampAndCRL[] newTimeStamps = new TimeStampAndCRL[timeStamps.length + 1]; System.arraycopy(timeStamps, 0, newTimeStamps, 0, timeStamps.length); newTimeStamps[timeStamps.length] = new TimeStampAndCRL(token.toCMSSignedData().toASN1Structure()); return new CMSTimeStampedData(new ContentInfo(CMSObjectIdentifiers.timestampedData, new TimeStampedData(timeStampedData.getDataUri(), timeStampedData.getMetaData(), timeStampedData.getContent(), new Evidence(new TimeStampTokenEvidence(newTimeStamps))))); }
TimeStampDataUtil(TimeStampedData timeStampedData) { this.metaDataUtil = new MetaDataUtil(timeStampedData.getMetaData()); Evidence evidence = timeStampedData.getTemporalEvidence(); this.timeStamps = evidence.getTstEvidence().toTimeStampAndCRLArray(); }
/** * Return a new timeStampedData object with the additional token attached. * * @throws CMSException */ public CMSTimeStampedData addTimeStamp(TimeStampToken token) throws CMSException { TimeStampAndCRL[] timeStamps = util.getTimeStamps(); TimeStampAndCRL[] newTimeStamps = new TimeStampAndCRL[timeStamps.length + 1]; System.arraycopy(timeStamps, 0, newTimeStamps, 0, timeStamps.length); newTimeStamps[timeStamps.length] = new TimeStampAndCRL(token.toCMSSignedData().getContentInfo()); return new CMSTimeStampedData(new ContentInfo(CMSObjectIdentifiers.timestampedData, new TimeStampedData(timeStampedData.getDataUri(), timeStampedData.getMetaData(), timeStampedData.getContent(), new Evidence(new TimeStampTokenEvidence(newTimeStamps))))); }