public CMSSignedData timestamp()

in jsign-core/src/main/java/net/jsign/timestamp/Timestamper.java [116:145]


    public CMSSignedData timestamp(DigestAlgorithm algo, CMSSignedData sigData) throws TimestampingException, IOException, CMSException {
        CMSSignedData token = null;
        
        // Retry the timestamping and failover other services if a TSA is unavailable for a short period of time
        int attempts = Math.max(retries, tsaurls.size());
        TimestampingException exception = new TimestampingException("Unable to complete the timestamping after " + attempts + " attempt" + (attempts > 1 ? "s" : ""));
        int count = 0;
        while (count < Math.max(retries, tsaurls.size())) {
            try {
                tsaurl = tsaurls.get(count % tsaurls.size());
                token = timestamp(algo, getEncryptedDigest(sigData));
                break;
            } catch (TimestampingException | IOException e) {
                exception.addSuppressed(e);
            }

            // pause before the next attempt
            try {
                Thread.sleep(retryWait * 1000L);
                count++;
            } catch (InterruptedException ie) {
            }
        }
        
        if (token == null) {
            throw exception;
        }
        
        return modifySignedData(sigData, getUnsignedAttributes(token), getExtraCertificates(token));
    }