Commit cf5aa5f8 authored by benjamin.ertl's avatar benjamin.ertl
Browse files

fix

parent d0abe699
......@@ -5,6 +5,7 @@ import java.io.InputStream;
import java.util.Map.Entry;
import java.util.Properties;
import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -15,6 +16,10 @@ public final class Utils {
private Utils() {
}
public static String encodeBase64(String string) {
return new String(Base64.encodeBase64(string.getBytes()));
}
public static Properties loadProperties() {
InputStream in = null;
Properties properties = new Properties();
......
......@@ -10,7 +10,6 @@ import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
import javax.net.ssl.SSLContext;
......@@ -41,6 +40,8 @@ import org.slf4j.LoggerFactory;
import com.google.common.io.ByteStreams;
import edu.kit.scc.Utils;
/**
* HTTP client implementation.
*
......@@ -86,7 +87,7 @@ public class HttpClient {
urlConnection.setRequestProperty("Accept", "*/*");
if (user != null && !user.isEmpty()) {
String value = Base64.getEncoder().encodeToString((user + ":" + password).getBytes());
String value = Utils.encodeBase64(user + ":" + password);
log.debug("Authorization: Basic {}", value);
urlConnection.setRequestProperty("Authorization", "Basic " + value);
}
......@@ -154,7 +155,7 @@ public class HttpClient {
urlConnection.setDoOutput(true);
if (user != null && !user.isEmpty()) {
String value = Base64.getEncoder().encodeToString((user + ":" + password).getBytes());
String value = Utils.encodeBase64(user + ":" + password);
log.debug("Authorization: Basic {}", value);
urlConnection.setRequestProperty("Authorization", "Basic " + value);
}
......
......@@ -3,7 +3,6 @@ package edu.kit.scc.http;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Base64;
import javax.net.ssl.HttpsURLConnection;
......@@ -12,6 +11,8 @@ import org.slf4j.LoggerFactory;
import com.google.common.io.ByteStreams;
import edu.kit.scc.Utils;
/**
* HTTPS client implementation.
*
......@@ -57,7 +58,7 @@ public class HttpsClient {
urlConnection.setRequestProperty("Accept", "*/*");
if (user != null && !user.isEmpty()) {
String value = Base64.getEncoder().encodeToString((user + ":" + password).getBytes());
String value = Utils.encodeBase64(user + ":" + password);
log.debug("Authorization: Basic {}", value);
urlConnection.setRequestProperty("Authorization", "Basic " + value);
}
......@@ -126,7 +127,7 @@ public class HttpsClient {
urlConnection.setDoOutput(true);
if (user != null && !user.isEmpty()) {
String value = Base64.getEncoder().encodeToString((user + ":" + password).getBytes());
String value = Utils.encodeBase64(user + ":" + password);
log.debug("Authorization: Basic {}", value);
urlConnection.setRequestProperty("Authorization", "Basic " + value);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment