javacryptographycertificaterfc3161

How to use an OnlineTSPSource with esig/dss Library?


I'm attempting to use an online timestamp authority (rfc3161) with the Digital Signature Service Java library. However, the following snippet (from their test cases, and similar to the one from their Cookbook):

String tspServer = "http://tsa.belgium.be/connect";
OnlineTSPSource otsp = new OnlineTSPSource(tspServer);
/* tried setting otsp.setDataLoader(new TimestampDataLoader());
   too, as it defaults to otsp.setDataLoader(new 
   NativeHTTPDataLoader()); the exception happens in both cases */
byte[] digest = DSSUtils.digest(DigestAlgorithm.SHA1, "Hello world".getBytes());
TimeStampToken timeStampResponse =
    otsp.getTimeStampResponse(DigestAlgorithm.SHA1, digest);

always ends with the following exception:

eu.europa.esig.dss.DSSException: 
java.util.concurrent.ExecutionException: java.lang.NoSuchMethodError: 
org.apache.commons.io.IOUtils.closeQuietly(Ljava/io/Closeable;)V

Already tried many different public rfc3161 servers (some listed here). Sure there's something wrong going on there, but, as a beginner, I cannot understand what is wrong (what method should be there).

If anyone could put me in the right direction to get the snippet working (or even be kind enough to comment a reliable startup guide on cades/xades/pades with Java's bouncycastle) I would be really grateful.


Solution

  • As stated in the comments by Marteen Bodewes and Mark Rotteveel, there was something wrong with the version of Apache Commons-IO in the classpath. The project is set using Apache Maven and there was an old Commons-IO version declared there as a dependency. In this case, it was enough to remove that declaration, so Maven could download the appropriate version that was declared as an esig/DSS dependency.

    esig/DSS version was 5.4 at the time.