From 95cb2394154a287afcd295590d741096985ff69a Mon Sep 17 00:00:00 2001 From: steckbrief Date: Wed, 4 Jan 2017 19:41:20 +0100 Subject: Added columns to fileparams table: url, original file name, key and iv auto download of files moved from MessageParser to MessageAdapter download and open file representation cleaned up --- .../conversationsplus/utils/UrlUtil.java | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/main/java/de/thedevstack/conversationsplus/utils/UrlUtil.java (limited to 'src/main/java/de/thedevstack/conversationsplus/utils/UrlUtil.java') 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 + } +} -- cgit v1.2.3