TSAClient.java (pdfbox-2.0.23-src) | : | TSAClient.java (pdfbox-2.0.24-src) | ||
---|---|---|---|---|
skipping to change at line 137 | skipping to change at line 137 | |||
// todo: support proxy servers | // todo: support proxy servers | |||
URLConnection connection = url.openConnection(); | URLConnection connection = url.openConnection(); | |||
connection.setDoOutput(true); | connection.setDoOutput(true); | |||
connection.setDoInput(true); | connection.setDoInput(true); | |||
connection.setRequestProperty("Content-Type", "application/timestamp-que ry"); | connection.setRequestProperty("Content-Type", "application/timestamp-que ry"); | |||
LOG.debug("Established connection to TSA server"); | LOG.debug("Established connection to TSA server"); | |||
if (username != null && password != null && !username.isEmpty() && !pass word.isEmpty()) | if (username != null && password != null && !username.isEmpty() && !pass word.isEmpty()) | |||
{ | { | |||
connection.setRequestProperty(username, password); | // See https://stackoverflow.com/questions/12732422/ (needs jdk8) | |||
// or see implementation in 3.0 | ||||
throw new UnsupportedOperationException("authentication not implemen | ||||
ted yet"); | ||||
} | } | |||
// read response | // read response | |||
OutputStream output = null; | OutputStream output = null; | |||
try | try | |||
{ | { | |||
output = connection.getOutputStream(); | output = connection.getOutputStream(); | |||
output.write(request); | output.write(request); | |||
} | } | |||
catch (IOException ex) | ||||
{ | ||||
LOG.error("Exception when writing to " + this.url, ex); | ||||
throw ex; | ||||
} | ||||
finally | finally | |||
{ | { | |||
IOUtils.closeQuietly(output); | IOUtils.closeQuietly(output); | |||
} | } | |||
LOG.debug("Waiting for response from TSA server"); | LOG.debug("Waiting for response from TSA server"); | |||
InputStream input = null; | InputStream input = null; | |||
byte[] response; | byte[] response; | |||
try | try | |||
{ | { | |||
input = connection.getInputStream(); | input = connection.getInputStream(); | |||
response = IOUtils.toByteArray(input); | response = IOUtils.toByteArray(input); | |||
} | } | |||
catch (IOException ex) | ||||
{ | ||||
LOG.error("Exception when reading from " + this.url, ex); | ||||
throw ex; | ||||
} | ||||
finally | finally | |||
{ | { | |||
IOUtils.closeQuietly(input); | IOUtils.closeQuietly(input); | |||
} | } | |||
LOG.debug("Received response from TSA server"); | LOG.debug("Received response from TSA server"); | |||
return response; | return response; | |||
} | } | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 14 lines changed or added |