Search in sources :

Example 1 with Evidence

use of com.github.zhenwei.pkix.util.asn1.cms.Evidence 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)))));
}
Also used : ASN1OctetString(com.github.zhenwei.core.asn1.ASN1OctetString) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) TimeStampAndCRL(com.github.zhenwei.pkix.util.asn1.cms.TimeStampAndCRL) TimeStampTokenEvidence(com.github.zhenwei.pkix.util.asn1.cms.TimeStampTokenEvidence) DERIA5String(com.github.zhenwei.core.asn1.DERIA5String) BEROctetString(com.github.zhenwei.core.asn1.BEROctetString) ContentInfo(com.github.zhenwei.pkix.util.asn1.cms.ContentInfo) ASN1IA5String(com.github.zhenwei.core.asn1.ASN1IA5String) TimeStampedData(com.github.zhenwei.pkix.util.asn1.cms.TimeStampedData) TimeStampTokenEvidence(com.github.zhenwei.pkix.util.asn1.cms.TimeStampTokenEvidence) Evidence(com.github.zhenwei.pkix.util.asn1.cms.Evidence) CMSException(com.github.zhenwei.pkix.cms.CMSException)

Example 2 with Evidence

use of com.github.zhenwei.pkix.util.asn1.cms.Evidence 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)))));
}
Also used : TimeStampTokenEvidence(com.github.zhenwei.pkix.util.asn1.cms.TimeStampTokenEvidence) ContentInfo(com.github.zhenwei.pkix.util.asn1.cms.ContentInfo) TimeStampedData(com.github.zhenwei.pkix.util.asn1.cms.TimeStampedData) TimeStampTokenEvidence(com.github.zhenwei.pkix.util.asn1.cms.TimeStampTokenEvidence) Evidence(com.github.zhenwei.pkix.util.asn1.cms.Evidence) TimeStampAndCRL(com.github.zhenwei.pkix.util.asn1.cms.TimeStampAndCRL)

Aggregations

ContentInfo (com.github.zhenwei.pkix.util.asn1.cms.ContentInfo)2 Evidence (com.github.zhenwei.pkix.util.asn1.cms.Evidence)2 TimeStampAndCRL (com.github.zhenwei.pkix.util.asn1.cms.TimeStampAndCRL)2 TimeStampTokenEvidence (com.github.zhenwei.pkix.util.asn1.cms.TimeStampTokenEvidence)2 TimeStampedData (com.github.zhenwei.pkix.util.asn1.cms.TimeStampedData)2 ASN1IA5String (com.github.zhenwei.core.asn1.ASN1IA5String)1 ASN1OctetString (com.github.zhenwei.core.asn1.ASN1OctetString)1 BEROctetString (com.github.zhenwei.core.asn1.BEROctetString)1 DERIA5String (com.github.zhenwei.core.asn1.DERIA5String)1 CMSException (com.github.zhenwei.pkix.cms.CMSException)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1