@@ -0,0 +1,2574 @@
+package org.bouncycastle.tsp.test;%0A%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.io.InputStream;%0A%0Aimport junit.framework.TestCase;%0Aimport org.bouncycastle.operator.DigestCalculator;%0Aimport org.bouncycastle.operator.DigestCalculatorProvider;%0Aimport org.bouncycastle.operator.bc.BcDigestCalculatorProvider;%0Aimport org.bouncycastle.tsp.TimeStampToken;%0Aimport org.bouncycastle.tsp.cms.CMSTimeStampedData;%0A%0Apublic class CMSTimeStampedDataTest%0A    extends TestCase%0A%7B%0A%0A    CMSTimeStampedData cmsTimeStampedData = null;%0A    String fileInput = %22FileDaFirmare.txt.tsd.der%22;%0A    String fileOutput = fileInput.substring(0, fileInput.indexOf(%22.tsd%22));%0A    private byte%5B%5D baseData;%0A%0A    protected void setUp()%0A        throws Exception%0A    %7B%0A        ByteArrayOutputStream origStream = new ByteArrayOutputStream();%0A        InputStream in = this.getClass().getResourceAsStream(fileInput);%0A        int ch;%0A%0A        while ((ch = in.read()) %3E= 0)%0A        %7B%0A            origStream.write(ch);%0A        %7D%0A%0A        origStream.close();%0A%0A        this.baseData = origStream.toByteArray();%0A%0A        cmsTimeStampedData = new CMSTimeStampedData(baseData);%0A    %7D%0A%0A    protected void tearDown()%0A        throws Exception%0A    %7B%0A        cmsTimeStampedData = null;%0A    %7D%0A%0A    public void testGetTimeStampTokens()%0A        throws Exception%0A    %7B%0A        TimeStampToken%5B%5D tokens = cmsTimeStampedData.getTimeStampTokens();%0A        assertEquals(3, tokens.length);%0A    %7D%0A%0A    public void testValidateAllTokens()%0A        throws Exception%0A    %7B%0A        DigestCalculatorProvider digestCalculatorProvider = new BcDigestCalculatorProvider();%0A%0A        DigestCalculator imprintCalculator = cmsTimeStampedData.getMessageImprintDigestCalculator(digestCalculatorProvider);%0A%0A        imprintCalculator.getOutputStream().write(cmsTimeStampedData.getContent());%0A%0A        byte%5B%5D digest = imprintCalculator.getDigest();%0A%0A        TimeStampToken%5B%5D tokens = cmsTimeStampedData.getTimeStampTokens();%0A        for (int i = 0; i %3C tokens.length; i++)%0A        %7B%0A            cmsTimeStampedData.validate(digestCalculatorProvider, digest, tokens%5Bi%5D);%0A        %7D%0A    %7D%0A%0A    public void testValidate()%0A        throws Exception%0A    %7B%0A        DigestCalculatorProvider digestCalculatorProvider = new BcDigestCalculatorProvider();%0A%0A        DigestCalculator imprintCalculator = cmsTimeStampedData.getMessageImprintDigestCalculator(digestCalculatorProvider);%0A%0A        imprintCalculator.getOutputStream().write(cmsTimeStampedData.getContent());%0A%0A        cmsTimeStampedData.validate(digestCalculatorProvider, imprintCalculator.getDigest());%0A    %7D%0A%0A%7D%0A

test for CMSTimeStampedData