if (url.getProtocol() != null &&
url.getProtocol().equalsIgnoreCase("https")) {
setupClientSSL(httpclient, url.getPort());
}
HttpDelete httpdel = new HttpDelete(tsUrl + "/" + URLEncoder.encode(token, "UTF-8"));
httpdel.setHeader("Accept", "application/json");
httpdel.setHeader("Accept-Charset", "UTF-8");
httpdel.setHeader("Authorization", request.getHeader("Authorization"));
httpdel.setHeader("TS-URL", request.getHeader("TS-URL"));
// Execute the request
HttpResponse authResponse = httpclient.execute(httpdel);
int status = authResponse.getStatusLine().getStatusCode();
if (status == 404) {
LOGGER.info("The authentication server " + tsUrl + " was not found.");
returnError(response, "The token server URL was not found",
RESTAuthConstants.NOTFOUND_TS_URL);
return;
}
// Get hold of the response entity
HttpEntity entity = authResponse.getEntity();
StringBuffer authResponseData = new StringBuffer();
// If the response does not enclose an entity, there is no need
// to worry about connection release
if (entity != null) {
InputStream instream = entity.getContent();
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(instream));
// do something useful with the response
authResponseData.append(reader.readLine());
} catch (RuntimeException ex) {
// In case of an unexpected exception you may want to abort
// the HTTP request in order to shut down the underlying
// connection and release it back to the connection manager.
httpdel.abort();
LOGGER.throwing(AuthServlet.class.getName(), "doLogout", ex);
throw ex;
} finally {
// Closing the input stream will trigger connection release
if (reader != null) {