diff options
author | steckbrief <steckbrief@chefmail.de> | 2017-01-04 19:41:20 +0100 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2017-01-04 19:41:20 +0100 |
commit | 95cb2394154a287afcd295590d741096985ff69a (patch) | |
tree | 51f0b10fa41844885fc4ec40164b80e5892e3316 /src/main/java/de/thedevstack/conversationsplus/utils/UrlUtil.java | |
parent | b85035c2bf57de75280ae0b4eedeff6fbf87e9eb (diff) |
Added columns to fileparams table: url, original file name, key and ivtrz/beta-5
auto download of files moved from MessageParser to MessageAdapter
download and open file representation cleaned up
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/utils/UrlUtil.java')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/utils/UrlUtil.java | 25 |
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 + } +} |