diff options
author | steckbrief <steckbrief@chefmail.de> | 2017-01-05 21:05:24 +0100 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2017-01-05 21:05:24 +0100 |
commit | c09e7f0a21f563359c69f0e4198c7563cd2d4809 (patch) | |
tree | a52009fa04da58a10bad7de19814e15e010fde7a /src/main/java/de/thedevstack/conversationsplus/utils/UrlUtil.java | |
parent | 867ee316619f814e6311668d0f2b910cecdd6393 (diff) | |
parent | 2586fe2b9d745c0666656acb6beb4020805dd220 (diff) |
Merge branch 'trz/rebase' into trz/rename
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..53bc24d6 --- /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 de.thedevstack.conversationsplus.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 + } +} |