private String getAuthToken(String token) { if(token == null || token.isEmpty()) { return null; } String path = this.protocol + "://" + this.server + "/api/auth"; String body = "{\"token\":\"" + token + "\"}"; HttpResponse response = WS.url(path).body(body).header("Content-Type", "application/json;charset=UTF-8").put(); int status = WS.getStatus(response); if(200 <= status && 300 > status) { String responseAsString = WS.getResponseAsString(response); if(responseAsString.startsWith("\"")) { responseAsString = responseAsString.substring(1); } if(responseAsString.endsWith("\"")) { responseAsString = responseAsString.substring(0, responseAsString.length() - 1); } return responseAsString; } else { this.logger.warn("Authentication with CloudConductor Server %s failed with status %s", this.server, status); } return null; } }
private String getAuthToken(String token) { if(token == null || token.isEmpty()) { return null; } String path = this.protocol + "://" + this.server + "/api/auth"; String body = "{\"token\":\"" + token + "\"}"; HTTPRequest httpRequest = WS.url(path).body(body).header("Content-Type", "application/json;charset=UTF-8"); try (HTTPResponse response = httpRequest.put()) { int status = response.getStatus(); if (200 <= status && 300 > status) { String responseAsString = response.getResponseAsString(); if (responseAsString.startsWith("\"")) { responseAsString = responseAsString.substring(1); } if (responseAsString.endsWith("\"")) { responseAsString = responseAsString.substring(0, responseAsString.length() - 1); } return responseAsString; } else { this.logger.warn("Authentication with CloudConductor Server {} failed with status {}", this.server, status); } } return null; } }