mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 07:56:19 +00:00
make oidc discovery work again
This commit is contained in:
parent
8d09a5c242
commit
e878ad3931
@ -20,11 +20,10 @@ class ConnectionValidator (
|
||||
var validationRetryCount = 0
|
||||
val client = OwnCloudClient(baseClient.baseUri, null, false)
|
||||
if (clearCookiesOnValidation) {
|
||||
client.cookiesForBaseUri = emptyList()
|
||||
client.clearCookies()
|
||||
} else {
|
||||
client.cookiesForBaseUri = baseClient.cookiesForBaseUri
|
||||
}
|
||||
//TODO: Also handle cookies
|
||||
|
||||
client.credentials = baseClient.credentials
|
||||
client.setFollowRedirects(true)
|
||||
|
@ -62,7 +62,6 @@ public class OwnCloudClient extends HttpClient {
|
||||
private static final int MAX_REDIRECTIONS_COUNT = 5;
|
||||
private static final int MAX_REPEAT_COUNT_WITH_FRESH_CREDENTIALS = 1;
|
||||
|
||||
private static byte[] sExhaustBuffer = new byte[1024];
|
||||
private static int sIntanceCounter = 0;
|
||||
private OwnCloudCredentials mCredentials = null;
|
||||
private int mInstanceNumber;
|
||||
@ -80,7 +79,7 @@ public class OwnCloudClient extends HttpClient {
|
||||
|
||||
private SingleSessionManager mSingleSessionManager = null;
|
||||
|
||||
private boolean mFollowRedirects;
|
||||
private boolean mFollowRedirects = false;
|
||||
|
||||
public OwnCloudClient(Uri baseUri, ConnectionValidator connectionValidator, boolean synchronizeRequests) {
|
||||
if (baseUri == null) {
|
||||
@ -357,6 +356,10 @@ public class OwnCloudClient extends HttpClient {
|
||||
HttpUrl.parse(mBaseUri.toString()));
|
||||
}
|
||||
|
||||
public void clearCookies() {
|
||||
setCookiesForBaseUri(new ArrayList<>());
|
||||
}
|
||||
|
||||
public OwnCloudVersion getOwnCloudVersion() {
|
||||
return mVersion;
|
||||
}
|
||||
@ -453,7 +456,7 @@ public class OwnCloudClient extends HttpClient {
|
||||
am.clearPassword(mAccount.getSavedAccount()); // being strict, only needed for Basic Auth credentials
|
||||
}
|
||||
|
||||
public boolean followRedirects() {
|
||||
public boolean getFollowRedirects() {
|
||||
return mFollowRedirects;
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,6 @@ import java.util.concurrent.TimeUnit;
|
||||
public class HttpClient {
|
||||
private static OkHttpClient sOkHttpClient;
|
||||
private static Context sContext;
|
||||
private static HashMap<String, List<Cookie>> sCookieStore = new HashMap<>();
|
||||
private static LogInterceptor sLogInterceptor;
|
||||
private static Interceptor sDebugInterceptor;
|
||||
|
||||
@ -68,11 +67,10 @@ public class HttpClient {
|
||||
NetworkUtils.getKnownServersStore(sContext));
|
||||
final SSLSocketFactory sslSocketFactory = getNewSslSocketFactory(trustManager);
|
||||
// Automatic cookie handling, NOT PERSISTENT
|
||||
final CookieJar cookieJar = new CookieJarImpl(sCookieStore);
|
||||
|
||||
// TODO: Not verifying the hostname against certificate. ask owncloud security human if this is ok.
|
||||
//.hostnameVerifier(new BrowserCompatHostnameVerifier());
|
||||
sOkHttpClient = buildNewOkHttpClient(sslSocketFactory, trustManager, cookieJar);
|
||||
sOkHttpClient = buildNewOkHttpClient(sslSocketFactory, trustManager);
|
||||
|
||||
} catch (Exception e) {
|
||||
Timber.e(e, "Could not setup SSL system.");
|
||||
@ -109,8 +107,7 @@ public class HttpClient {
|
||||
return sslContext.getSocketFactory();
|
||||
}
|
||||
|
||||
private static OkHttpClient buildNewOkHttpClient(SSLSocketFactory sslSocketFactory, X509TrustManager trustManager,
|
||||
CookieJar cookieJar) {
|
||||
private static OkHttpClient buildNewOkHttpClient(SSLSocketFactory sslSocketFactory, X509TrustManager trustManager){
|
||||
return new OkHttpClient.Builder()
|
||||
.addNetworkInterceptor(getLogInterceptor())
|
||||
.addNetworkInterceptor(DebugInterceptorFactory.INSTANCE.getInterceptor())
|
||||
@ -121,7 +118,6 @@ public class HttpClient {
|
||||
.followRedirects(false)
|
||||
.sslSocketFactory(sslSocketFactory, trustManager)
|
||||
.hostnameVerifier((asdf, usdf) -> true)
|
||||
.cookieJar(cookieJar)
|
||||
.build();
|
||||
}
|
||||
|
||||
@ -132,10 +128,6 @@ public class HttpClient {
|
||||
return sLogInterceptor;
|
||||
}
|
||||
|
||||
public static List<Cookie> getCookiesFromUrl(HttpUrl httpUrl) {
|
||||
return sCookieStore.get(httpUrl.host());
|
||||
}
|
||||
|
||||
public Context getContext() {
|
||||
return sContext;
|
||||
}
|
||||
@ -143,8 +135,4 @@ public class HttpClient {
|
||||
public static void setContext(Context context) {
|
||||
sContext = context;
|
||||
}
|
||||
|
||||
public void clearCookies() {
|
||||
sCookieStore.clear();
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ class CheckPathExistenceRemoteOperation(
|
||||
private set
|
||||
|
||||
override fun run(client: OwnCloudClient): RemoteOperationResult<Boolean> {
|
||||
val previousFollowRedirects = client.followRedirects()
|
||||
val previousFollowRedirects = client.getFollowRedirects()
|
||||
return try {
|
||||
val stringUrl =
|
||||
if (isUserLogged) client.baseFilesWebDavUri.toString()
|
||||
@ -71,7 +71,6 @@ class CheckPathExistenceRemoteOperation(
|
||||
setConnectionTimeout(TIMEOUT.toLong(), TimeUnit.SECONDS)
|
||||
}
|
||||
|
||||
client.setFollowRedirects(false)
|
||||
var status = client.executeHttpMethod(propFindMethod)
|
||||
if (previousFollowRedirects) {
|
||||
redirectionPath = client.followRedirection(propFindMethod)
|
||||
|
@ -77,8 +77,6 @@ public class ReadRemoteFolderOperation extends RemoteOperation<ArrayList<RemoteF
|
||||
DavConstants.DEPTH_1,
|
||||
DavUtils.getAllPropset());
|
||||
|
||||
client.setFollowRedirects(true);
|
||||
|
||||
int status = client.executeHttpMethod(propfindMethod);
|
||||
|
||||
if (isSuccess(status)) {
|
||||
|
@ -55,6 +55,7 @@ class GetOIDCDiscoveryRemoteOperation : RemoteOperation<OIDCDiscoveryResponse>()
|
||||
addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE)
|
||||
}
|
||||
|
||||
getMethod.setFollowRedirects(true)
|
||||
val status = client.executeHttpMethod(getMethod)
|
||||
|
||||
val responseBody = getMethod.getResponseBodyAsString()
|
||||
|
Loading…
x
Reference in New Issue
Block a user