mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Clear basic credentials before applying new ones
This commit is contained in:
parent
81aa417cbf
commit
4f0cd82a7d
@ -25,7 +25,7 @@ package com.owncloud.android.lib.common.authentication;
|
||||
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.interceptors.BasicAuthInterceptor;
|
||||
import com.owncloud.android.lib.common.interceptors.HttpInterceptor;
|
||||
import com.owncloud.android.lib.common.interceptors.HttpInterceptor.RequestInterceptor;
|
||||
|
||||
import org.apache.commons.httpclient.UsernamePasswordCredentials;
|
||||
import org.apache.commons.httpclient.auth.AuthPolicy;
|
||||
@ -65,10 +65,12 @@ public class OwnCloudBasicCredentials implements OwnCloudCredentials {
|
||||
List<String> authPrefs = new ArrayList<>(1);
|
||||
authPrefs.add(AuthPolicy.BASIC);
|
||||
|
||||
for (HttpInterceptor.RequestInterceptor requestInterceptor :
|
||||
client.getBaseOkHttpInterceptor().getRequestInterceptors()) {
|
||||
ArrayList<RequestInterceptor> requestInterceptors = client.getBaseOkHttpInterceptor().getRequestInterceptors();
|
||||
|
||||
// Clear previous basic credentials
|
||||
for (RequestInterceptor requestInterceptor : requestInterceptors) {
|
||||
if (requestInterceptor instanceof BasicAuthInterceptor) {
|
||||
return;
|
||||
requestInterceptors.remove(requestInterceptor);
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,7 +79,7 @@ public class OwnCloudBasicCredentials implements OwnCloudCredentials {
|
||||
new BasicAuthInterceptor(Credentials.basic(mUsername, mPassword))
|
||||
);
|
||||
|
||||
//TODO
|
||||
//TODO Update from here down
|
||||
client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
|
||||
client.getParams().setAuthenticationPreemptive(mAuthenticationPreemptive);
|
||||
client.getParams().setCredentialCharset(OwnCloudCredentialsFactory.CREDENTIAL_CHARSET);
|
||||
|
@ -82,13 +82,4 @@ public class HttpInterceptor implements Interceptor {
|
||||
public ArrayList<ResponseInterceptor> getResponseInterceptors() {
|
||||
return mResponseInterceptors;
|
||||
}
|
||||
|
||||
public boolean requestWithCredentials () {
|
||||
for (RequestInterceptor requestInterceptor : mRequestInterceptors) {
|
||||
if (requestInterceptor instanceof BasicAuthInterceptor) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user