HttpHost host = new HttpHost(hostname, port);
HttpPost post = new HttpPost("/tsa");
TimeStampRequestGenerator generator = new TimeStampRequestGenerator();
TimeStampRequest timeStampRequest = generator.generate(TSPAlgorithms.SHA1, DigestHelper.digest("this is a test message"));
TimeStampRequest otherTimeStampRequest = generator.generate(TSPAlgorithms.SHA1, DigestHelper.digest("this is another test message"));
ByteArrayEntity entity = new ByteArrayEntity(Base64.encode(timeStampRequest.getEncoded()));
post.setHeader("Content-Type", TimestampServlet.TIMESTAMP_QUERY_CONTENT_TYPE);
post.setHeader(TimestampServlet.TRANSFER_ENCODING_HEADER, TimestampServlet.TRANSFER_ENCODING_BASE64);