X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/03c30519b11e9772eecdc74f89d350bdecd20361..de273586b4106171a3940ce5ec2c2b3712430c8c:/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 b8b27eaa..82d8a37f 100644 --- a/lib/src/main/java/org/asamk/signal/manager/DeviceLinkInfo.java +++ b/lib/src/main/java/org/asamk/signal/manager/DeviceLinkInfo.java @@ -20,14 +20,14 @@ public class DeviceLinkInfo { final ECPublicKey deviceKey; public static DeviceLinkInfo parseDeviceLinkUri(URI linkUri) throws InvalidKeyException { - final String rawQuery = linkUri.getRawQuery(); + final var rawQuery = linkUri.getRawQuery(); if (isEmpty(rawQuery)) { throw new RuntimeException("Invalid device link uri"); } - Map query = getQueryMap(rawQuery); - String deviceIdentifier = query.get("uuid"); - String publicKeyEncoded = query.get("pub_key"); + var query = getQueryMap(rawQuery); + var deviceIdentifier = query.get("uuid"); + var publicKeyEncoded = query.get("pub_key"); if (isEmpty(deviceIdentifier) || isEmpty(publicKeyEncoded)) { throw new RuntimeException("Invalid device link uri"); @@ -39,18 +39,18 @@ public class DeviceLinkInfo { } catch (IllegalArgumentException e) { throw new RuntimeException("Invalid device link uri", e); } - ECPublicKey deviceKey = Curve.decodePoint(publicKeyBytes, 0); + var deviceKey = Curve.decodePoint(publicKeyBytes, 0); return new DeviceLinkInfo(deviceIdentifier, deviceKey); } private static Map getQueryMap(String query) { - String[] params = query.split("&"); - Map map = new HashMap<>(); - for (String param : params) { - final String[] paramParts = param.split("="); - String name = URLDecoder.decode(paramParts[0], StandardCharsets.UTF_8); - String value = URLDecoder.decode(paramParts[1], StandardCharsets.UTF_8); + 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; @@ -62,7 +62,7 @@ public class DeviceLinkInfo { } public String createDeviceLinkUri() { - final String deviceKeyString = Base64.getEncoder().encodeToString(deviceKey.serialize()).replace("=", ""); + final var deviceKeyString = Base64.getEncoder().encodeToString(deviceKey.serialize()).replace("=", ""); return "tsdevice:/?uuid=" + URLEncoder.encode(deviceIdentifier, StandardCharsets.UTF_8) + "&pub_key="