Search in sources :

Example 1 with TimeStampTokenRes

use of xades4j.providers.TimeStampTokenProvider.TimeStampTokenRes in project xades4j by luisgoncalves.

the class DataGenBaseTimeStamp method generatePropertyData.

@Override
public final PropertyDataObject generatePropertyData(TProp prop, PropertiesDataGenerationContext ctx) throws PropertyDataGenerationException {
    Algorithm c14n = this.algsProvider.getCanonicalizationAlgorithmForTimeStampProperties();
    try {
        TimeStampDigestInput digestInput = this.tsInputFactory.newTimeStampDigestInput(c14n);
        addPropSpecificTimeStampInput(prop, digestInput, ctx);
        TimeStampTokenRes tsTknRes = this.tsTokenProvider.getTimeStampToken(digestInput.getBytes(), this.algsProvider.getDigestAlgorithmForTimeStampProperties());
        return createPropDataObj(prop, c14n, tsTknRes, ctx);
    } catch (UnsupportedAlgorithmException ex) {
        throw new PropertyDataGenerationException(prop, ex.getMessage(), ex);
    } catch (CannotAddDataToDigestInputException ex) {
        throw new PropertyDataGenerationException(prop, "cannot create time stamp input", ex);
    } catch (TimeStampTokenGenerationException ex) {
        throw new PropertyDataGenerationException(prop, "cannot get a time-stamp", ex);
    }
}
Also used : CannotAddDataToDigestInputException(xades4j.utils.CannotAddDataToDigestInputException) TimeStampDigestInput(xades4j.utils.TimeStampDigestInput) UnsupportedAlgorithmException(xades4j.UnsupportedAlgorithmException) TimeStampTokenRes(xades4j.providers.TimeStampTokenProvider.TimeStampTokenRes) Algorithm(xades4j.algorithms.Algorithm) TimeStampTokenGenerationException(xades4j.providers.TimeStampTokenGenerationException)

Example 2 with TimeStampTokenRes

use of xades4j.providers.TimeStampTokenProvider.TimeStampTokenRes in project xades4j by luisgoncalves.

the class HttpTimeStampTokenProviderTest method testGetTimeStampToken.

@Test
public void testGetTimeStampToken() throws Exception {
    System.out.println("getTimeStampToken");
    byte[] tsDigestInput = "TestDigestInput".getBytes();
    String digestAlgUri = MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA1;
    HttpTimeStampTokenProvider instance = new HttpTimeStampTokenProvider(new DefaultMessageDigestProvider(), new TSAHttpData("http://tss.accv.es:8318/tsa"));
    TimeStampTokenRes result = instance.getTimeStampToken(tsDigestInput, digestAlgUri);
    assertNotNull(result);
    assertNotNull(result.encodedTimeStampToken);
    assertNotNull(result.timeStampTime);
}
Also used : TimeStampTokenRes(xades4j.providers.TimeStampTokenProvider.TimeStampTokenRes) Test(org.junit.Test)

Aggregations

TimeStampTokenRes (xades4j.providers.TimeStampTokenProvider.TimeStampTokenRes)2 Test (org.junit.Test)1 UnsupportedAlgorithmException (xades4j.UnsupportedAlgorithmException)1 Algorithm (xades4j.algorithms.Algorithm)1 TimeStampTokenGenerationException (xades4j.providers.TimeStampTokenGenerationException)1 CannotAddDataToDigestInputException (xades4j.utils.CannotAddDataToDigestInputException)1 TimeStampDigestInput (xades4j.utils.TimeStampDigestInput)1