Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7636420 authored by Ricki Hirner's avatar Ricki Hirner
Browse files

Update to okhttp 3.12.0

parent 626287e7
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line

buildscript {
    ext.kotlin_version = '1.2.71'
    ext.kotlin_version = '1.3.10'
    ext.dokka_version = '0.9.17'

    repositories {
@@ -9,7 +9,7 @@ buildscript {
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:${dokka_version}"
    }
@@ -25,7 +25,7 @@ apply plugin: 'kotlin-android'
apply plugin: 'org.jetbrains.dokka-android'

ext {
    okhttp_version = '3.11.0'
    okhttp_version = '3.12.0'
}

android {
+17 −18
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ class BasicDigestAuthHandler(
): Authenticator, Interceptor {

    companion object {
        private const val HEADER_AUTHENTICATE = "WWW-Authenticate"
        private const val HEADER_AUTHORIZATION = "Authorization"

        // cached digest parameters
@@ -55,8 +54,8 @@ class BasicDigestAuthHandler(
    }

    // cached authentication schemes
    private var basicAuth: HttpUtils.AuthScheme? = null
    private var digestAuth: HttpUtils.AuthScheme? = null
    private var basicAuth: Challenge? = null
    private var digestAuth: Challenge? = null


    fun authenticateRequest(request: Request, response: Response?): Request? {
@@ -73,31 +72,31 @@ class BasicDigestAuthHandler(

            if (basicAuth == null && digestAuth == null && request.isHttps) {
                Constants.log.fine("Trying Basic auth preemptively")
                basicAuth = HttpUtils.AuthScheme("Basic")
                basicAuth = Challenge("Basic", "")
            }

        } else {
            // we're processing a 401 response

            var newBasicAuth: HttpUtils.AuthScheme? = null
            var newDigestAuth: HttpUtils.AuthScheme? = null
            for (scheme in HttpUtils.parseWwwAuthenticate(response.headers(HEADER_AUTHENTICATE)))
            var newBasicAuth: Challenge? = null
            var newDigestAuth: Challenge? = null
            for (challenge in response.challenges())
                when {
                    "Basic".equals(scheme.name, true) -> {
                    "Basic".equals(challenge.scheme(), true) -> {
                        basicAuth?.let {
                            Constants.log.warning("Basic credentials didn't work last time -> aborting")
                            basicAuth = null
                            return null
                        }
                        newBasicAuth = scheme
                        newBasicAuth = challenge
                    }
                    "Digest".equals(scheme.name, true) -> {
                        if (digestAuth != null && !"true".equals(scheme.params["stale"], true)) {
                    "Digest".equals(challenge.scheme(), true) -> {
                        if (digestAuth != null && !"true".equals(challenge.authParams()["stale"], true)) {
                            Constants.log.warning("Digest credentials didn't work last time and server nonce has not expired -> aborting")
                            digestAuth = null
                            return null
                        }
                        newDigestAuth = scheme
                        newDigestAuth = challenge
                    }
                }

@@ -132,16 +131,16 @@ class BasicDigestAuthHandler(
        return null
    }

    fun digestRequest(request: Request, digest: HttpUtils.AuthScheme?): Request? {
    fun digestRequest(request: Request, digest: Challenge?): Request? {
        if (digest == null)
            return null

        val realm = digest.params["realm"]
        val opaque = digest.params["opaque"]
        val nonce = digest.params["nonce"]
        val realm = digest.authParams()["realm"]
        val opaque = digest.authParams()["opaque"]
        val nonce = digest.authParams()["nonce"]

        val algorithm = Algorithm.determine(digest.params["algorithm"])
        val qop = Protection.selectFrom(digest.params["qop"])
        val algorithm = Algorithm.determine(digest.authParams()["algorithm"])
        val qop = Protection.selectFrom(digest.authParams()["qop"])

        // build response parameters
        var response: String? = null
+2 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ object HttpUtils {
        return value.split(',').filter { it.isNotEmpty() }.toTypedArray()
    }

    @Deprecated("Use okhttp Challenge API")
    fun parseWwwAuthenticate(wwwAuths: List<String>): List<AuthScheme> {
        /* WWW-Authenticate  = "WWW-Authenticate" ":" 1#challenge

@@ -124,6 +125,7 @@ object HttpUtils {
    }


    @Deprecated("Use okhttp Challenge API")
    class AuthScheme(
            val name: String
    ) {