Эх сурвалжийг харах

parse multiple auth headers and pick "basic" if exists

tobiasKaminsky 8 жил өмнө
parent
commit
599256d9c9

+ 1 - 1
build.gradle

@@ -179,7 +179,7 @@ dependencies {
     compile name: 'touch-image-view'
     compile 'com.android.support:multidex:1.0.1'
 
-    compile 'com.github.nextcloud:android-library:1.0.18'
+    compile 'com.github.nextcloud:android-library:authInNC12-SNAPSHOT'
     compile "com.android.support:support-v4:${supportLibraryVersion}"
     compile "com.android.support:design:${supportLibraryVersion}"
     compile 'com.jakewharton:disklrucache:2.0.2'

+ 8 - 3
src/main/java/com/owncloud/android/operations/DetectAuthenticationMethodOperation.java

@@ -97,9 +97,14 @@ public class DetectAuthenticationMethodOperation extends RemoteOperation {
 
         // analyze response  
         if (result.getHttpCode() == HttpStatus.SC_UNAUTHORIZED) {
-            String authRequest = ((result.getAuthenticateHeader()).trim()).toLowerCase();
-            if (authRequest.startsWith("basic") || authRequest.startsWith("bearer")) {
-                authMethod = AuthenticationMethod.BASIC_HTTP_AUTH;
+            ArrayList<String> authHeaders = result.getAuthenticateHeaders();
+
+            for (String header : authHeaders) {
+                // currently we only support basic auth
+                if (header.toLowerCase().startsWith("basic")) {
+                    authMethod = AuthenticationMethod.BASIC_HTTP_AUTH;
+                    break;
+                }
             }
             // else - fall back to UNKNOWN