class TimestampGenerator {

    public byte[] generateToken(byte[] hash, DigestType digestType, BigInteger nonce)
        throws TimeStampException {

        final TimeStampRequestGenerator reqGen = new TimeStampRequestGenerator();
        reqGen.setCertReq(true);
        final TimeStampRequest request = reqGen.generate(digestToOid(digestType), hash, nonce);

        try {
            TimeStampResponse timeStampResponse = timeStampSignature.sign(request);
            // lets validate de the timestamp
            timeStampResponse.validate(request);
            return timeStampResponse.getEncoded();
        } catch (OperatorCreationException | TSPException | CertificateEncodingException | IOException e) {
            throw new TimeStampException("unable to generate timestamp token", e);
        }
    }

    public  TimestampGenerator(TimeStampSignature timeStampSignature);

}