mirror of
https://github.com/aljazceru/signal-cli.git
synced 2026-01-26 00:54:19 +01:00
Return URI instead of String
This commit is contained in:
@@ -5,6 +5,7 @@ import org.whispersystems.libsignal.ecc.Curve;
|
||||
import org.whispersystems.libsignal.ecc.ECPublicKey;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -61,11 +62,15 @@ public class DeviceLinkInfo {
|
||||
this.deviceKey = deviceKey;
|
||||
}
|
||||
|
||||
public String createDeviceLinkUri() {
|
||||
public URI createDeviceLinkUri() {
|
||||
final var deviceKeyString = Base64.getEncoder().encodeToString(deviceKey.serialize()).replace("=", "");
|
||||
return "tsdevice:/?uuid="
|
||||
+ URLEncoder.encode(deviceIdentifier, StandardCharsets.UTF_8)
|
||||
+ "&pub_key="
|
||||
+ URLEncoder.encode(deviceKeyString, StandardCharsets.UTF_8);
|
||||
try {
|
||||
return new URI("tsdevice:/?uuid="
|
||||
+ URLEncoder.encode(deviceIdentifier, StandardCharsets.UTF_8)
|
||||
+ "&pub_key="
|
||||
+ URLEncoder.encode(deviceKeyString, StandardCharsets.UTF_8));
|
||||
} catch (URISyntaxException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.whispersystems.signalservice.internal.util.DynamicCredentialsProvider
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
public class ProvisioningManager {
|
||||
@@ -86,7 +87,7 @@ public class ProvisioningManager {
|
||||
return new ProvisioningManager(pathConfig, serviceConfiguration, userAgent);
|
||||
}
|
||||
|
||||
public String getDeviceLinkUri() throws TimeoutException, IOException {
|
||||
public URI getDeviceLinkUri() throws TimeoutException, IOException {
|
||||
var deviceUuid = accountManager.getNewDeviceUuid();
|
||||
|
||||
return new DeviceLinkInfo(deviceUuid, identityKey.getPublicKey().getPublicKey()).createDeviceLinkUri();
|
||||
|
||||
Reference in New Issue
Block a user