use of com.github.zhenwei.pkix.util.asn1.cms.TimeStampAndCRL in project LinLong-Java by zhenwei1108.
the class CMSTimeStampedDataGenerator method generate.
public CMSTimeStampedData generate(TimeStampToken timeStamp, InputStream content) throws CMSException {
ByteArrayOutputStream contentOut = new ByteArrayOutputStream();
if (content != null) {
try {
Streams.pipeAll(content, contentOut);
} catch (IOException e) {
throw new CMSException("exception encapsulating content: " + e.getMessage(), e);
}
}
ASN1OctetString encContent = null;
if (contentOut.size() != 0) {
encContent = new BEROctetString(contentOut.toByteArray());
}
TimeStampAndCRL stamp = new TimeStampAndCRL(timeStamp.toCMSSignedData().toASN1Structure());
ASN1IA5String asn1DataUri = null;
if (dataUri != null) {
asn1DataUri = new DERIA5String(dataUri.toString());
}
return new CMSTimeStampedData(new ContentInfo(CMSObjectIdentifiers.timestampedData, new TimeStampedData(asn1DataUri, metaData, encContent, new Evidence(new TimeStampTokenEvidence(stamp)))));
}
use of com.github.zhenwei.pkix.util.asn1.cms.TimeStampAndCRL in project LinLong-Java by zhenwei1108.
the class TimeStampDataUtil method calculateNextHash.
byte[] calculateNextHash(DigestCalculator calculator) throws CMSException {
TimeStampAndCRL tspToken = timeStamps[timeStamps.length - 1];
OutputStream out = calculator.getOutputStream();
try {
out.write(tspToken.getEncoded(ASN1Encoding.DER));
out.close();
return calculator.getDigest();
} catch (IOException e) {
throw new CMSException("exception calculating hash: " + e.getMessage(), e);
}
}
use of com.github.zhenwei.pkix.util.asn1.cms.TimeStampAndCRL in project LinLong-Java by zhenwei1108.
the class CMSTimeStampedData method addTimeStamp.
/**
* 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)))));
}
Aggregations