Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
korvatovskaya.s committed Jan 19, 2025
1 parent e56a1b8 commit 3f0b541
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions src/main/java/Diadoc/Api/auth/AuthenticateClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,13 @@ public void authenticate(X509Certificate currentCert, boolean autoConfirm) throw

public byte[] authenticateAutoConfirm(X509Certificate currentCert, @Nullable String key, @Nullable String id, @Nullable Boolean saveBinding) throws DiadocSdkException {
try {
authManager.clearCredentials();

var request = RequestBuilder
.post(new URIBuilder(diadocHttpClient.getBaseUrl())
.setPath(V_3_AUTHENTICATE)
.addParameter("type", "certificate")
.build())
.addHeader("Content-Type", "application/octet-stream")
.setEntity(new ByteArrayEntity(currentCert.getEncoded()));
addServiceHeaders(request, key, id);
var response = diadocHttpClient.performRequest(request);
var response = authenticate(currentCert, key, id);

String token = getDecryptedToken(response, currentCert);
confirmAuthenticationByCertificate(currentCert, token, saveBinding);

return response;
} catch (URISyntaxException | IOException | CertificateEncodingException | TokenDecryptException ex) {
} catch (TokenDecryptException | DiadocSdkException ex) {
throw new DiadocSdkException(ex);
}
}
Expand All @@ -130,9 +120,7 @@ public byte[] authenticate(X509Certificate currentCert, @Nullable String key, @N
.addHeader("Content-Type", "application/octet-stream")
.setEntity(new ByteArrayEntity(currentCert.getEncoded()));
addServiceHeaders(request, key, id);
var response = diadocHttpClient.performRequest(request);

return response;
return diadocHttpClient.performRequest(request);
} catch (URISyntaxException | IOException | CertificateEncodingException ex) {
throw new DiadocSdkException(ex);
}
Expand Down

0 comments on commit 3f0b541

Please sign in to comment.