Use the JDK-provided Base64 encoder/decoder.

This commit is contained in:
Jon Chambers
2021-04-23 15:26:27 -04:00
committed by Jon Chambers
parent 0e8d4f9a61
commit 6196856a7c
31 changed files with 126 additions and 4341 deletions

View File

@@ -13,6 +13,7 @@ import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.security.cert.CertificateException;
import java.time.Duration;
import java.util.Base64;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
@@ -20,7 +21,6 @@ import org.whispersystems.textsecuregcm.auth.ExternalServiceCredentialGenerator;
import org.whispersystems.textsecuregcm.auth.ExternalServiceCredentials;
import org.whispersystems.textsecuregcm.configuration.SecureBackupServiceConfiguration;
import org.whispersystems.textsecuregcm.http.FaultTolerantHttpClient;
import org.whispersystems.textsecuregcm.util.Base64;
/**
* A client for sending requests to Signal's secure value recovery service on behalf of authenticated users.
@@ -56,7 +56,8 @@ public class SecureBackupClient {
final HttpRequest request = HttpRequest.newBuilder()
.uri(deleteUri)
.DELETE()
.header("Authorization", "Basic " + Base64.encodeBytes((credentials.getUsername() + ":" + credentials.getPassword()).getBytes(StandardCharsets.UTF_8)))
.header("Authorization", "Basic " + Base64.getEncoder().encodeToString(
(credentials.getUsername() + ":" + credentials.getPassword()).getBytes(StandardCharsets.UTF_8)))
.build();
return httpClient.sendAsync(request, HttpResponse.BodyHandlers.ofString()).thenApply(response -> {