Return URI instead of String
This commit is contained in:
parent
2935b96070
commit
9944b666b0
@ -5,6 +5,7 @@ import org.whispersystems.libsignal.ecc.Curve;
|
|||||||
import org.whispersystems.libsignal.ecc.ECPublicKey;
|
import org.whispersystems.libsignal.ecc.ECPublicKey;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@ -61,11 +62,15 @@ public class DeviceLinkInfo {
|
|||||||
this.deviceKey = deviceKey;
|
this.deviceKey = deviceKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String createDeviceLinkUri() {
|
public URI createDeviceLinkUri() {
|
||||||
final var deviceKeyString = Base64.getEncoder().encodeToString(deviceKey.serialize()).replace("=", "");
|
final var deviceKeyString = Base64.getEncoder().encodeToString(deviceKey.serialize()).replace("=", "");
|
||||||
return "tsdevice:/?uuid="
|
try {
|
||||||
+ URLEncoder.encode(deviceIdentifier, StandardCharsets.UTF_8)
|
return new URI("tsdevice:/?uuid="
|
||||||
+ "&pub_key="
|
+ URLEncoder.encode(deviceIdentifier, StandardCharsets.UTF_8)
|
||||||
+ URLEncoder.encode(deviceKeyString, 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.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URI;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
public class ProvisioningManager {
|
public class ProvisioningManager {
|
||||||
@ -86,7 +87,7 @@ public class ProvisioningManager {
|
|||||||
return new ProvisioningManager(pathConfig, serviceConfiguration, userAgent);
|
return new ProvisioningManager(pathConfig, serviceConfiguration, userAgent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDeviceLinkUri() throws TimeoutException, IOException {
|
public URI getDeviceLinkUri() throws TimeoutException, IOException {
|
||||||
var deviceUuid = accountManager.getNewDeviceUuid();
|
var deviceUuid = accountManager.getNewDeviceUuid();
|
||||||
|
|
||||||
return new DeviceLinkInfo(deviceUuid, identityKey.getPublicKey().getPublicKey()).createDeviceLinkUri();
|
return new DeviceLinkInfo(deviceUuid, identityKey.getPublicKey().getPublicKey()).createDeviceLinkUri();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user