aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/utils/UrlUtil.java
blob: 53bc24d64a33bd06dacc5920c802026d69f5f670 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
    }
}