// Check for successful login
if (response.getStatusLine().getStatusCode() >= 400) {
LOG.warn("Failed to login against " + login.getLoginFormURL() + " to obtain authentication for access to "
+ target.toString());
throw new HttpException(response.getStatusLine().getStatusCode(), "Login attempt failed - "
+ response.getStatusLine().getReasonPhrase());
}
// Otherwise assume a successful login
LOG.info("Successfully logged in against " + login.getLoginFormURL()
+ " and obtained authentication for access to " + target.toString());
login.setCookies(client.getCookieStore());
// Consume the response to free up the connection
EntityUtils.consumeQuietly(response.getEntity());
} catch (UnsupportedEncodingException e) {
throw new HttpException("UTF-8 encoding not supported on your platform", e);
} catch (IOException e) {
throw new HttpException("Error making login request", e);
}
}
}