use of com.emc.storageos.xtremio.restapi.model.XtremIOAuthInfo in project coprhd-controller by CoprHD.
the class XtremIOClient method authenticate.
@Override
protected void authenticate() throws XtremIOApiException {
ClientResponse response = null;
try {
XtremIOAuthInfo authInfo = new XtremIOAuthInfo();
authInfo.setPassword(_password);
authInfo.setUsername(_username);
String body = getJsonForEntity(authInfo);
URI requestURI = _base.resolve(URI.create(XtremIOConstants.XTREMIO_BASE_STR));
response = _client.resource(requestURI).type(MediaType.APPLICATION_JSON).post(ClientResponse.class, body);
if (response.getClientResponseStatus() != ClientResponse.Status.OK && response.getClientResponseStatus() != ClientResponse.Status.CREATED) {
throw XtremIOApiException.exceptions.authenticationFailure(_base.toString());
}
_authToken = response.getHeaders().getFirst(XtremIOConstants.AUTH_TOKEN_HEADER);
} catch (Exception e) {
throw XtremIOApiException.exceptions.authenticationFailure(_base.toString());
} finally {
closeResponse(response);
}
}
Aggregations