- private String getAuthorizationContent() throws DatafileTaskException {
- String jwtToken = HttpUtils.getJWTToken(fileServerData);
- if (shouldUseBasicAuth(jwtToken)) {
- return HttpUtils.basicAuthContent(this.fileServerData.userId, this.fileServerData.password);
- }
- return HttpUtils.jwtAuthContent(jwtToken);
- }
-
- private boolean shouldUseBasicAuth(String jwtToken) throws DatafileTaskException {
- return basicAuthValidNotPresentOrThrow() && jwtToken.isEmpty();
- }
-
- protected boolean basicAuthValidNotPresentOrThrow() throws DatafileTaskException {
- if (isAuthDataEmpty()) {
- return false;
- }
- if (HttpUtils.isBasicAuthDataFilled(fileServerData)) {
- return true;
- }
- throw new DatafileTaskException("Not sufficient basic auth data for file.");
- }
-
- private boolean isAuthDataEmpty() {
- return this.fileServerData.userId.isEmpty() && this.fileServerData.password.isEmpty();
- }
-
- protected HttpResponse makeCall(HttpGet httpGet) throws IOException, DatafileTaskException {