Conversations/src/main/java/eu/siacs/conversations/http/AesGcmURLStreamHandler.java

24 lines
722 B
Java
Raw Normal View History

2017-02-07 13:31:54 -05:00
package eu.siacs.conversations.http;
2017-02-07 13:32:12 -05:00
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;
import java.util.regex.Pattern;
2017-02-07 13:32:12 -05:00
2017-02-07 14:07:57 -05:00
public class AesGcmURLStreamHandler extends URLStreamHandler {
/**
* This matches a 48 or 44 byte IV + KEY hex combo, like used in http/aesgcm upload anchors
*/
public static final Pattern IV_KEY = Pattern.compile("([A-Fa-f0-9]{2}){48}|([A-Fa-f0-9]{2}){44}");
2017-02-07 14:07:57 -05:00
public static final String PROTOCOL_NAME = "aesgcm";
2017-02-07 13:32:12 -05:00
@Override
protected URLConnection openConnection(URL url) throws IOException {
2017-02-07 14:07:57 -05:00
return new URL("https"+url.toString().substring(url.getProtocol().length())).openConnection();
2017-02-07 13:32:12 -05:00
}
2017-02-07 13:31:54 -05:00
}