use of com.b2international.snowowl.core.identity.Credentials in project snow-owl by b2ihealthcare.
the class CisClient method login.
public void login() {
final String tokenBeforeLogin = getToken();
LogUtils.logUserAccess(LOGGER, username, "Logging in to Component Identifier service.");
HttpPost request = null;
try {
final Credentials credentials = new Credentials(username, password);
request = httpPost("login", credentials);
final String response = execute(request);
final JsonNode node = mapper.readValue(response, JsonNode.class);
String tokenAfterLogin = node.get("token").asText();
// If this replacement fails, someone changed the token by the time we got here; let them have their ways.
if (token.compareAndSet(tokenBeforeLogin, tokenAfterLogin)) {
LOGGER.info("Received token from CIS: {}", tokenAfterLogin);
}
} catch (IOException e) {
throw new SnowowlRuntimeException("Exception while logging in.", e);
} finally {
if (null != request)
release(request);
}
}
Aggregations