aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/utils/UrlUtil.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/utils/UrlUtil.java')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/utils/UrlUtil.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/UrlUtil.java b/src/main/java/de/thedevstack/conversationsplus/utils/UrlUtil.java
new file mode 100644
index 00000000..50c42288
--- /dev/null
+++ b/src/main/java/de/thedevstack/conversationsplus/utils/UrlUtil.java
@@ -0,0 +1,25 @@
+package de.thedevstack.conversationsplus.utils;
+
+import java.net.URL;
+
+import eu.siacs.conversations.utils.CryptoHelper;
+
+/**
+ * This utility class provides helper methods to handle URLs.
+ */
+
+public final class UrlUtil {
+ public static byte[] getIvAndKeyFromURL(URL url) {
+ if (null == url) {
+ return null;
+ }
+ String reference = url.getRef();
+ boolean linkHasIvAndKey = reference != null && reference.matches("([A-Fa-f0-9]{2}){48}");
+
+ return linkHasIvAndKey ? CryptoHelper.hexToBytes(reference) : null;
+ }
+
+ private UrlUtil() {
+ // Helper Class
+ }
+}