mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Apply changes requested in code review
This commit is contained in:
parent
4153ee4e35
commit
1b4ce388b3
@ -26,7 +26,9 @@ android {
|
|||||||
versionCode = 10000401
|
versionCode = 10000401
|
||||||
versionName = "1.0.4.1"
|
versionName = "1.0.4.1"
|
||||||
|
|
||||||
manifestPlaceholders = [appAuthRedirectScheme: 'oc']
|
// This is pretty ugly but manifest placeholders don't seem to work very well when using different modules
|
||||||
|
// See https://github.com/openid/AppAuth-Android/issues/325
|
||||||
|
manifestPlaceholders = [appAuthRedirectScheme: '']
|
||||||
}
|
}
|
||||||
|
|
||||||
lintOptions {
|
lintOptions {
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
package com.owncloud.android.lib.common.authentication.oauth;
|
|
||||||
|
|
||||||
import android.net.Uri;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import net.openid.appauth.Preconditions;
|
|
||||||
import net.openid.appauth.connectivity.ConnectionBuilder;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Based on {@link net.openid.appauth.connectivity.DefaultConnectionBuilder} but permitting http connections in addition
|
|
||||||
* to https connections
|
|
||||||
*/
|
|
||||||
public final class OAuthConnectionBuilder implements ConnectionBuilder {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The singleton instance of the default connection builder.
|
|
||||||
*/
|
|
||||||
public static final OAuthConnectionBuilder INSTANCE = new OAuthConnectionBuilder();
|
|
||||||
|
|
||||||
private static final int CONNECTION_TIMEOUT_MS = (int) TimeUnit.SECONDS.toMillis(15);
|
|
||||||
private static final int READ_TIMEOUT_MS = (int) TimeUnit.SECONDS.toMillis(10);
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public HttpURLConnection openConnection(@NonNull Uri uri) throws IOException {
|
|
||||||
Preconditions.checkNotNull(uri, "url must not be null");
|
|
||||||
HttpURLConnection conn = (HttpURLConnection) new URL(uri.toString()).openConnection();
|
|
||||||
conn.setConnectTimeout(CONNECTION_TIMEOUT_MS);
|
|
||||||
conn.setReadTimeout(READ_TIMEOUT_MS);
|
|
||||||
conn.setInstanceFollowRedirects(false);
|
|
||||||
return conn;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.owncloud.android.lib.common.authentication.oauth
|
||||||
|
|
||||||
|
import android.net.Uri
|
||||||
|
import net.openid.appauth.Preconditions
|
||||||
|
import net.openid.appauth.connectivity.ConnectionBuilder
|
||||||
|
import java.io.IOException
|
||||||
|
import java.net.HttpURLConnection
|
||||||
|
import java.net.URL
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Based on [net.openid.appauth.connectivity.DefaultConnectionBuilder] but permitting http connections in addition
|
||||||
|
* to https connections
|
||||||
|
*/
|
||||||
|
class OAuthConnectionBuilder : ConnectionBuilder {
|
||||||
|
@Throws(IOException::class)
|
||||||
|
override fun openConnection(uri: Uri): HttpURLConnection {
|
||||||
|
Preconditions.checkNotNull(uri, "url must not be null")
|
||||||
|
val conn = URL(uri.toString()).openConnection() as HttpURLConnection
|
||||||
|
return conn.apply {
|
||||||
|
connectTimeout = CONNECTION_TIMEOUT_MS
|
||||||
|
readTimeout = READ_TIMEOUT_MS
|
||||||
|
instanceFollowRedirects = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val CONNECTION_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(15).toInt()
|
||||||
|
private val READ_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(10).toInt()
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user