Loading build.gradle +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 { Loading @@ -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}" } Loading @@ -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 { Loading src/main/java/at/bitfire/dav4android/BasicDigestAuthHandler.kt +17 −18 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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? { Loading @@ -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 } } Loading Loading @@ -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 Loading src/main/java/at/bitfire/dav4android/HttpUtils.kt +2 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -124,6 +125,7 @@ object HttpUtils { } @Deprecated("Use okhttp Challenge API") class AuthScheme( val name: String ) { Loading Loading
build.gradle +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 { Loading @@ -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}" } Loading @@ -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 { Loading
src/main/java/at/bitfire/dav4android/BasicDigestAuthHandler.kt +17 −18 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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? { Loading @@ -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 } } Loading Loading @@ -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 Loading
src/main/java/at/bitfire/dav4android/HttpUtils.kt +2 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -124,6 +125,7 @@ object HttpUtils { } @Deprecated("Use okhttp Challenge API") class AuthScheme( val name: String ) { Loading