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