AesGcmURLStreamHandler.java

 1package eu.siacs.conversations.http;
 2
 3import java.io.IOException;
 4import java.net.URL;
 5import java.net.URLConnection;
 6import java.net.URLStreamHandler;
 7import java.util.regex.Pattern;
 8
 9
10public class AesGcmURLStreamHandler extends URLStreamHandler {
11
12    /**
13     * This matches a 48 or 44 byte IV + KEY hex combo, like used in http/aesgcm upload anchors
14     */
15    public static final Pattern IV_KEY = Pattern.compile("([A-Fa-f0-9]{2}){48}|([A-Fa-f0-9]{2}){44}");
16
17    public static final String PROTOCOL_NAME = "aesgcm";
18
19    @Override
20    protected URLConnection openConnection(URL url) throws IOException {
21        return new URL("https"+url.toString().substring(url.getProtocol().length())).openConnection();
22    }
23}