use of org.openstack4j.openstack.identity.v2.domain.RaxApiKeyCredentials in project openstack4j by ContainX.
the class OSAuthenticator method authenticateV2.
private static OSClientV2 authenticateV2(org.openstack4j.openstack.identity.v2.domain.Auth auth, SessionInfo info, Config config) {
HttpRequest<KeystoneAccess> request = HttpRequest.builder(KeystoneAccess.class).header(ClientConstants.HEADER_OS4J_AUTH, TOKEN_INDICATOR).endpoint(info.endpoint).method(HttpMethod.POST).path("/tokens").config(config).entity(auth).build();
HttpResponse response = HttpExecutor.create().execute(request);
if (response.getStatus() >= 400) {
try {
throw mapException(response.getStatusMessage(), response.getStatus());
} finally {
HttpEntityHandler.closeQuietly(response);
}
}
KeystoneAccess access = response.getEntity(KeystoneAccess.class);
if (auth.getType() == Type.CREDENTIALS) {
access = access.applyContext(info.endpoint, (Credentials) auth);
} else if (auth.getType() == Type.RAX_APIKEY) {
access = access.applyContext(info.endpoint, (RaxApiKeyCredentials) auth);
} else {
access = access.applyContext(info.endpoint, (org.openstack4j.openstack.identity.v2.domain.TokenAuth) auth);
}
if (!info.reLinkToExistingSession)
return OSClientSession.OSClientSessionV2.createSession(access, info.perspective, info.provider, config);
OSClientSession.OSClientSessionV2 current = (OSClientSessionV2) OSClientSession.getCurrent();
current.access = access;
return current;
}
Aggregations