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

@@ -5,13 +5,12 @@
package org.whispersystems.textsecuregcm.websocket;
import org.whispersystems.textsecuregcm.util.Base64;
import java.security.SecureRandom;
import java.util.Base64;
public class ProvisioningAddress extends WebsocketAddress {
public ProvisioningAddress(String address, int id) throws InvalidWebsocketAddressException {
public ProvisioningAddress(String address, int id) {
super(address, id);
}
@@ -24,14 +23,9 @@ public class ProvisioningAddress extends WebsocketAddress {
}
public static ProvisioningAddress generate() {
try {
byte[] random = new byte[16];
new SecureRandom().nextBytes(random);
byte[] random = new byte[16];
new SecureRandom().nextBytes(random);
return new ProvisioningAddress(Base64.encodeBytesWithoutPadding(random)
.replace('+', '-').replace('/', '_'), 0);
} catch (InvalidWebsocketAddressException e) {
throw new AssertionError(e);
}
return new ProvisioningAddress(Base64.getUrlEncoder().withoutPadding().encodeToString(random), 0);
}
}