X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=inline;f=ves-nf-oam-adopter%2Fves-nf-oam-adopter-pm-sb-rest-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fo%2Fran%2Foam%2Fnf%2Foam%2Fadopter%2Fpm%2Fsb%2Frest%2Fclient%2Fhttp%2FTokenHandler.java;h=a154d11328f5016d2dccb6a0bcb568780f9027c7;hb=2b8bb7bfd6f3586ecdf914ce4ed95f21dd0ee46b;hp=26c62b597e52ab8158dbb2580c43cdcf11682eca;hpb=368d47f6e9f0263a3c6cf24837f4e93331a40a49;p=oam%2Fnf-oam-adopter.git diff --git a/ves-nf-oam-adopter/ves-nf-oam-adopter-pm-sb-rest-client/src/main/java/org/o/ran/oam/nf/oam/adopter/pm/sb/rest/client/http/TokenHandler.java b/ves-nf-oam-adopter/ves-nf-oam-adopter-pm-sb-rest-client/src/main/java/org/o/ran/oam/nf/oam/adopter/pm/sb/rest/client/http/TokenHandler.java index 26c62b5..a154d11 100644 --- a/ves-nf-oam-adopter/ves-nf-oam-adopter-pm-sb-rest-client/src/main/java/org/o/ran/oam/nf/oam/adopter/pm/sb/rest/client/http/TokenHandler.java +++ b/ves-nf-oam-adopter/ves-nf-oam-adopter-pm-sb-rest-client/src/main/java/org/o/ran/oam/nf/oam/adopter/pm/sb/rest/client/http/TokenHandler.java @@ -8,7 +8,6 @@ import java.util.Base64; import java.util.concurrent.ExecutionException; import lombok.AccessLevel; import lombok.NoArgsConstructor; -import org.apache.hc.client5.http.async.methods.SimpleHttpRequest; import org.apache.hc.client5.http.async.methods.SimpleHttpRequests; import org.apache.hc.client5.http.async.methods.SimpleHttpResponse; import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient; @@ -31,15 +30,15 @@ public final class TokenHandler { public static synchronized String returnToken(final CloseableHttpAsyncClient client, final String tokenEndpoint, final Adapter adapter) throws ExecutionException, InterruptedException { final String host = HTTPS + adapter.getHostIpAddress(); - final SimpleHttpRequest request = SimpleHttpRequests.post(host + tokenEndpoint); - final String basicAuth = Base64.getEncoder().encodeToString( + final var request = SimpleHttpRequests.post(host + tokenEndpoint); + final var basicAuth = Base64.getEncoder().encodeToString( (adapter.getUsername() + ":" + adapter.getPassword()).getBytes(StandardCharsets.UTF_8)); request.setHeader(HttpHeaders.AUTHORIZATION, "Basic " + basicAuth); request.addHeader(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON_VALUE); request.addHeader(HttpHeaders.ACCEPT, APPLICATION_JSON_VALUE); final SimpleHttpResponse response = client.execute(request, null).get(); - final String statusLine = new StatusLine(response).toString(); + final var statusLine = new StatusLine(response).toString(); if (response.getCode() != HttpStatus.SC_OK) { throw new TokenGenerationException("Failed to obtain a token for host " + host + ": " + statusLine); }