From ed010a2188f58e0581a95506cf7eecc1cac35d9c Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 27 Oct 2016 17:06:19 -0700 Subject: Add back basic auth support --- .../java/github/daneren2005/dsub/service/RESTMusicService.java | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app/src/main/java/github') 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()); -- cgit v1.2.3