From c5a1df417fcbc3864fb6a75c019d41ee44984a5e Mon Sep 17 00:00:00 2001 From: theScrabi Date: Tue, 24 Jul 2018 10:34:38 +0200 Subject: [PATCH] fixed barear authentication --- .../lib/common/authentication/OwnCloudBasicCredentials.java | 5 ++--- .../common/authentication/OwnCloudBearerCredentials.java | 6 +++--- .../common/authentication/OwnCloudCredentialsFactory.java | 3 +-- .../common/authentication/OwnCloudSamlSsoCredentials.java | 3 +-- src/com/owncloud/android/lib/common/http/HttpConstants.java | 4 ++-- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/com/owncloud/android/lib/common/authentication/OwnCloudBasicCredentials.java b/src/com/owncloud/android/lib/common/authentication/OwnCloudBasicCredentials.java index 19ad1a59..66c0a1db 100644 --- a/src/com/owncloud/android/lib/common/authentication/OwnCloudBasicCredentials.java +++ b/src/com/owncloud/android/lib/common/authentication/OwnCloudBasicCredentials.java @@ -52,11 +52,10 @@ public class OwnCloudBasicCredentials implements OwnCloudCredentials { @Override public void applyTo(OwnCloudClient client) { // Clear previous basic credentials - HttpClient.deleteHeaderForAllRequests(HttpConstants.BASIC_AUTHORIZATION_HEADER); - HttpClient.deleteHeaderForAllRequests(HttpConstants.BEARER_AUTHORIZATION_HEADER); + HttpClient.deleteHeaderForAllRequests(HttpConstants.AUTHORIZATION_HEADER); HttpClient.deleteHeaderForAllRequests(HttpConstants.COOKIE_HEADER); - HttpClient.addHeaderForAllRequests(HttpConstants.BASIC_AUTHORIZATION_HEADER, + HttpClient.addHeaderForAllRequests(HttpConstants.AUTHORIZATION_HEADER, Credentials.basic(mUsername, mPassword)); } diff --git a/src/com/owncloud/android/lib/common/authentication/OwnCloudBearerCredentials.java b/src/com/owncloud/android/lib/common/authentication/OwnCloudBearerCredentials.java index f3d1ec08..a53712d6 100644 --- a/src/com/owncloud/android/lib/common/authentication/OwnCloudBearerCredentials.java +++ b/src/com/owncloud/android/lib/common/authentication/OwnCloudBearerCredentials.java @@ -40,11 +40,11 @@ public class OwnCloudBearerCredentials implements OwnCloudCredentials { @Override public void applyTo(OwnCloudClient client) { // Clear previous credentials - HttpClient.deleteHeaderForAllRequests(HttpConstants.BASIC_AUTHORIZATION_HEADER); - HttpClient.deleteHeaderForAllRequests(HttpConstants.BEARER_AUTHORIZATION_HEADER); + HttpClient.deleteHeaderForAllRequests(HttpConstants.AUTHORIZATION_HEADER); HttpClient.deleteHeaderForAllRequests(HttpConstants.COOKIE_HEADER); - HttpClient.addHeaderForAllRequests(HttpConstants.BEARER_AUTHORIZATION_HEADER, mAccessToken); + HttpClient.addHeaderForAllRequests(HttpConstants.AUTHORIZATION_HEADER, + HttpConstants.BEARER_AUTHORIZATION_KEY + mAccessToken); } @Override diff --git a/src/com/owncloud/android/lib/common/authentication/OwnCloudCredentialsFactory.java b/src/com/owncloud/android/lib/common/authentication/OwnCloudCredentialsFactory.java index 1049d1e5..a7f2ff80 100644 --- a/src/com/owncloud/android/lib/common/authentication/OwnCloudCredentialsFactory.java +++ b/src/com/owncloud/android/lib/common/authentication/OwnCloudCredentialsFactory.java @@ -67,8 +67,7 @@ public class OwnCloudCredentialsFactory { @Override public void applyTo(OwnCloudClient client) { // Clear previous basic credentials - HttpClient.deleteHeaderForAllRequests(HttpConstants.BASIC_AUTHORIZATION_HEADER); - HttpClient.deleteHeaderForAllRequests(HttpConstants.BEARER_AUTHORIZATION_HEADER); + HttpClient.deleteHeaderForAllRequests(HttpConstants.AUTHORIZATION_HEADER); HttpClient.deleteHeaderForAllRequests(HttpConstants.COOKIE_HEADER); } diff --git a/src/com/owncloud/android/lib/common/authentication/OwnCloudSamlSsoCredentials.java b/src/com/owncloud/android/lib/common/authentication/OwnCloudSamlSsoCredentials.java index 3cba25d7..a01e05da 100644 --- a/src/com/owncloud/android/lib/common/authentication/OwnCloudSamlSsoCredentials.java +++ b/src/com/owncloud/android/lib/common/authentication/OwnCloudSamlSsoCredentials.java @@ -40,8 +40,7 @@ public class OwnCloudSamlSsoCredentials implements OwnCloudCredentials { @Override public void applyTo(OwnCloudClient client) { // Clear previous credentials - HttpClient.deleteHeaderForAllRequests(HttpConstants.BASIC_AUTHORIZATION_HEADER); - HttpClient.deleteHeaderForAllRequests(HttpConstants.BEARER_AUTHORIZATION_HEADER); + HttpClient.deleteHeaderForAllRequests(HttpConstants.AUTHORIZATION_HEADER); HttpClient.deleteHeaderForAllRequests(HttpConstants.COOKIE_HEADER); HttpClient.addHeaderForAllRequests(HttpConstants.COOKIE_HEADER, mSessionCookie); diff --git a/src/com/owncloud/android/lib/common/http/HttpConstants.java b/src/com/owncloud/android/lib/common/http/HttpConstants.java index 86e39df7..80558a54 100644 --- a/src/com/owncloud/android/lib/common/http/HttpConstants.java +++ b/src/com/owncloud/android/lib/common/http/HttpConstants.java @@ -33,9 +33,9 @@ public class HttpConstants { *************************************************** HEADERS *********************************************** ***********************************************************************************************************/ - public static final String BASIC_AUTHORIZATION_HEADER = "Authorization"; + public static final String AUTHORIZATION_HEADER = "Authorization"; public static final String COOKIE_HEADER = "Cookie"; - public static final String BEARER_AUTHORIZATION_HEADER = "Bearer "; + public static final String BEARER_AUTHORIZATION_KEY = "Bearer "; public static final String USER_AGENT_HEADER = "User-Agent"; public static final String IF_MATCH_HEADER = "If-Match"; public static final String IF_NONE_MATCH_HEADER = "If-None-Match";