aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2016-10-27 17:06:19 -0700
committerScott Jackson <daneren2005@gmail.com>2016-10-27 17:06:19 -0700
commited010a2188f58e0581a95506cf7eecc1cac35d9c (patch)
treef8f7c5cd64f797b85ec4e752c8db324c05b82687 /app
parent979b43d2fbf4478ecbbc67d47b0e70e63731f61a (diff)
downloaddsub-ed010a2188f58e0581a95506cf7eecc1cac35d9c.tar.gz
dsub-ed010a2188f58e0581a95506cf7eecc1cac35d9c.tar.bz2
dsub-ed010a2188f58e0581a95506cf7eecc1cac35d9c.zip
Add back basic auth support
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java b/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java
index 913e30bf..1aa1d212 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java
@@ -39,6 +39,7 @@ import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
+import android.util.Base64;
import android.util.Log;
import com.google.android.gms.security.ProviderInstaller;
@@ -1897,6 +1898,13 @@ public class RESTMusicService implements MusicService {
sslConnection.setHostnameVerifier(selfSignedHostnameVerifier);
}
+ SharedPreferences prefs = Util.getPreferences(context);
+ int instance = getInstance(context);
+ String username = prefs.getString(Constants.PREFERENCES_KEY_USERNAME + instance, null);
+ String password = prefs.getString(Constants.PREFERENCES_KEY_PASSWORD + instance, null);
+ String encoded = Base64.encodeToString((username + ":" + password).getBytes("UTF-8"), Base64.NO_WRAP);;
+ connection.setRequestProperty("Authorization", "Basic " + encoded);
+
// Force the connection to initiate
if(connection.getResponseCode() >= 500) {
throw new IOException("Error code: " + connection.getResponseCode());