X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/3cf7721cd7112c4997c35ac95dca7fad305dfd12..f7f882e834f33702e4cc36d9a20e0a89ed76dec8:/lib/src/main/java/org/asamk/signal/manager/DeviceLinkInfo.java diff --git a/lib/src/main/java/org/asamk/signal/manager/DeviceLinkInfo.java b/lib/src/main/java/org/asamk/signal/manager/DeviceLinkInfo.java index ca6e305c..356cb47d 100644 --- a/lib/src/main/java/org/asamk/signal/manager/DeviceLinkInfo.java +++ b/lib/src/main/java/org/asamk/signal/manager/DeviceLinkInfo.java @@ -1,18 +1,16 @@ package org.asamk.signal.manager; import org.asamk.signal.manager.api.InvalidDeviceLinkException; -import org.whispersystems.libsignal.InvalidKeyException; -import org.whispersystems.libsignal.ecc.Curve; -import org.whispersystems.libsignal.ecc.ECPublicKey; +import org.asamk.signal.manager.util.Utils; +import org.signal.libsignal.protocol.InvalidKeyException; +import org.signal.libsignal.protocol.ecc.Curve; +import org.signal.libsignal.protocol.ecc.ECPublicKey; import java.net.URI; import java.net.URISyntaxException; -import java.net.URLDecoder; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.Base64; -import java.util.HashMap; -import java.util.Map; import static org.whispersystems.signalservice.internal.util.Util.isEmpty; @@ -24,7 +22,7 @@ public record DeviceLinkInfo(String deviceIdentifier, ECPublicKey deviceKey) { throw new RuntimeException("Invalid device link uri"); } - var query = getQueryMap(rawQuery); + var query = Utils.getQueryMap(rawQuery); var deviceIdentifier = query.get("uuid"); var publicKeyEncoded = query.get("pub_key"); @@ -48,18 +46,6 @@ public record DeviceLinkInfo(String deviceIdentifier, ECPublicKey deviceKey) { return new DeviceLinkInfo(deviceIdentifier, deviceKey); } - private static Map getQueryMap(String query) { - var params = query.split("&"); - var map = new HashMap(); - for (var param : params) { - final var paramParts = param.split("="); - var name = URLDecoder.decode(paramParts[0], StandardCharsets.UTF_8); - var value = URLDecoder.decode(paramParts[1], StandardCharsets.UTF_8); - map.put(name, value); - } - return map; - } - public URI createDeviceLinkUri() { final var deviceKeyString = Base64.getEncoder().encodeToString(deviceKey.serialize()).replace("=", ""); try {