@Override
public List<? extends Session> login(String agent, String id, String password)
throws IOException, InterruptedException, AuthenticationException {
Object payload = new AuthenticatePayload(new Agent(agent), id, password);
HttpRequest request = HttpRequest
.post(authUrl)
.bodyJson(payload)
.execute();
if (request.getResponseCode() != 200) {
ErrorResponse error = request.returnContent().asJson(ErrorResponse.class);
throw new AuthenticationException(error.getErrorMessage(), error.getErrorMessage());
} else {
AuthenticateResponse response = request.returnContent().asJson(AuthenticateResponse.class);
return response.getAvailableProfiles();
}
}