- String authorizationContent = getAuthorizationContent();
- this.client =
- HttpClient.create(pool).keepAlive(true).headers(h -> h.add("Authorization", authorizationContent));
-
- logger.trace("httpClient, auth header was set.");
- }
-
- protected String getAuthorizationContent() throws DatafileTaskException {
- String jwtToken = HttpUtils.getJWTToken(fileServerData);
- if (!jwtToken.isEmpty()) {
- return HttpUtils.jwtAuthContent(jwtToken);
- }
- if (!HttpUtils.isBasicAuthDataFilled(fileServerData)) {
- throw new DatafileTaskException("Not sufficient basic auth data for file.");
+ final String authorizationContent = this.securityContext.getBearerAuthToken();
+ this.client = HttpClient.create(pool).keepAlive(true);
+ if (!authorizationContent.isEmpty()) {
+ this.client = this.client.headers(h -> h.add("Authorization", "Bearer " + authorizationContent));
+ logger.trace("httpClient, auth header was set.");
+ } else if (!this.fileServerData.password.isEmpty()) {
+ String basicAuthContent =
+ HttpUtils.basicAuthContent(this.fileServerData.userId, this.fileServerData.password);
+ this.client = this.client.headers(h -> h.add("Authorization", basicAuthContent));