Loading README.md +5 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,11 @@ dav4jvm needs a working XmlPullParser (XPP). On Android, the system already come XPP and you don't need to include one; on other systems, you may need to import for instance `org.ogce:xpp3` to get dav4jvm to work. ## Custom properties If you use custom WebDAV properties, register the corresponding factories with `PropertyRegistery.register()` before calling other dav4jvm methods. ## Contact / License Loading build.gradle.kts +5 −11 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ import org.jetbrains.dokka.gradle.DokkaTask object Libs { // okhttp HTTP library const val okhttpVersion = "4.5.0" const val okhttpVersion = "4.6.0" // XmlPullParser library const val xpp3Version = "1.1.6" Loading @@ -15,10 +15,10 @@ repositories { } plugins { kotlin("jvm") version "1.3.71" kotlin("jvm") version "1.3.72" id("com.github.kukuhyoniatmoko.buildconfigkotlin") version "1.0.5" id("org.jetbrains.dokka") version "0.10.0" id("org.jetbrains.dokka") version "0.10.1" maven } Loading @@ -36,17 +36,11 @@ tasks { dependencies { implementation(kotlin("stdlib")) // okhttp api(platform("com.squareup.okhttp3:okhttp-bom:${Libs.okhttpVersion}")) api("com.squareup.okhttp3:okhttp") // use Kotlin-friendly okhttp 2.x implementation("com.squareup.okio:okio:2.+") api("com.squareup.okhttp3:okhttp:${Libs.okhttpVersion}") implementation("org.apache.commons:commons-lang3:3.9") api("org.ogce:xpp3:${Libs.xpp3Version}") testImplementation("com.squareup.okhttp3:mockwebserver") testImplementation("com.squareup.okhttp3:mockwebserver:${Libs.okhttpVersion}") } buildConfigKotlin { Loading src/main/kotlin/at/bitfire/dav4jvm/BasicDigestAuthHandler.kt +14 −14 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ class BasicDigestAuthHandler( domain?.let { val host = request.url.host if (!domain.equals(UrlUtils.hostToDomain(host), true)) { Constants.log.warning("Not authenticating against $host because it doesn't belong to $domain") Dav4jvm.log.warning("Not authenticating against $host because it doesn't belong to $domain") return null } } Loading @@ -69,7 +69,7 @@ class BasicDigestAuthHandler( // we're not processing a 401 response if (basicAuth == null && digestAuth == null && request.isHttps) { Constants.log.fine("Trying Basic auth preemptively") Dav4jvm.log.fine("Trying Basic auth preemptively") basicAuth = Challenge("Basic", "") } Loading @@ -82,7 +82,7 @@ class BasicDigestAuthHandler( when { "Basic".equals(challenge.scheme, true) -> { basicAuth?.let { Constants.log.warning("Basic credentials didn't work last time -> aborting") Dav4jvm.log.warning("Basic credentials didn't work last time -> aborting") basicAuth = null return null } Loading @@ -90,7 +90,7 @@ class BasicDigestAuthHandler( } "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") Dav4jvm.log.warning("Digest credentials didn't work last time and server nonce has not expired -> aborting") digestAuth = null return null } Loading @@ -105,12 +105,12 @@ class BasicDigestAuthHandler( // we MUST prefer Digest auth [https://tools.ietf.org/html/rfc2617#section-4.6] when { digestAuth != null -> { Constants.log.fine("Adding Digest authorization request for ${request.url}") Dav4jvm.log.fine("Adding Digest authorization request for ${request.url}") return digestRequest(request, digestAuth) } basicAuth != null -> { Constants.log.fine("Adding Basic authorization header for ${request.url}") Dav4jvm.log.fine("Adding Basic authorization header for ${request.url}") /* In RFC 2617 (obsolete), there was no encoding for credentials defined, although one can interpret it as "use ISO-8859-1 encoding". This has been clarified by RFC 7617, Loading @@ -123,7 +123,7 @@ class BasicDigestAuthHandler( } response != null -> Constants.log.warning("No supported authentication scheme") Dav4jvm.log.warning("No supported authentication scheme") } return null Loading @@ -148,13 +148,13 @@ class BasicDigestAuthHandler( if (realm != null) params.add("realm=${quotedString(realm)}") else { Constants.log.warning("No realm provided, aborting Digest auth") Dav4jvm.log.warning("No realm provided, aborting Digest auth") return null } if (nonce != null) params.add("nonce=${quotedString(nonce)}") else { Constants.log.warning("No nonce provided, aborting Digest auth") Dav4jvm.log.warning("No nonce provided, aborting Digest auth") return null } if (opaque != null) Loading Loading @@ -183,7 +183,7 @@ class BasicDigestAuthHandler( else -> null } Constants.log.finer("A1=$a1") Dav4jvm.log.finer("A1=$a1") val a2: String? = when (qop) { Protection.Auth -> Loading @@ -193,18 +193,18 @@ class BasicDigestAuthHandler( val body = request.body "$method:$digestURI:" + (if (body != null) h(body) else h("")) } catch(e: IOException) { Constants.log.warning("Couldn't get entity-body for hash calculation") Dav4jvm.log.warning("Couldn't get entity-body for hash calculation") null } } } Constants.log.finer("A2=$a2") Dav4jvm.log.finer("A2=$a2") if (a1 != null && a2 != null) response = kd(h(a1), "$nonce:$ncValue:$clientNonce:${qop.qop}:${h(a2)}") } else { Constants.log.finer("Using legacy Digest auth") Dav4jvm.log.finer("Using legacy Digest auth") // legacy (backwards compatibility with RFC 2069) if (algorithm == Algorithm.MD5) { Loading Loading @@ -238,7 +238,7 @@ class BasicDigestAuthHandler( MD5_SESSION.algorithm.equals(paramValue, true) -> MD5_SESSION else -> { Constants.log.warning("Ignoring unknown hash algorithm: $paramValue") Dav4jvm.log.warning("Ignoring unknown hash algorithm: $paramValue") null } } Loading src/main/kotlin/at/bitfire/dav4jvm/Constants.kt→src/main/kotlin/at/bitfire/dav4jvm/Dav4jvm.kt +1 −4 Original line number Diff line number Diff line Loading @@ -6,13 +6,10 @@ package at.bitfire.dav4jvm import BuildConfig import java.util.logging.Logger object Constants { object Dav4jvm { var log = Logger.getLogger("dav4jvm")!! const val okhttpVersion = BuildConfig.okhttpVersion } src/main/kotlin/at/bitfire/dav4jvm/DavAddressBook.kt +1 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ import java.util.logging.Logger class DavAddressBook @JvmOverloads constructor( httpClient: OkHttpClient, location: HttpUrl, log: Logger = Constants.log log: Logger = Dav4jvm.log ): DavCollection(httpClient, location, log) { companion object { Loading Loading
README.md +5 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,11 @@ dav4jvm needs a working XmlPullParser (XPP). On Android, the system already come XPP and you don't need to include one; on other systems, you may need to import for instance `org.ogce:xpp3` to get dav4jvm to work. ## Custom properties If you use custom WebDAV properties, register the corresponding factories with `PropertyRegistery.register()` before calling other dav4jvm methods. ## Contact / License Loading
build.gradle.kts +5 −11 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ import org.jetbrains.dokka.gradle.DokkaTask object Libs { // okhttp HTTP library const val okhttpVersion = "4.5.0" const val okhttpVersion = "4.6.0" // XmlPullParser library const val xpp3Version = "1.1.6" Loading @@ -15,10 +15,10 @@ repositories { } plugins { kotlin("jvm") version "1.3.71" kotlin("jvm") version "1.3.72" id("com.github.kukuhyoniatmoko.buildconfigkotlin") version "1.0.5" id("org.jetbrains.dokka") version "0.10.0" id("org.jetbrains.dokka") version "0.10.1" maven } Loading @@ -36,17 +36,11 @@ tasks { dependencies { implementation(kotlin("stdlib")) // okhttp api(platform("com.squareup.okhttp3:okhttp-bom:${Libs.okhttpVersion}")) api("com.squareup.okhttp3:okhttp") // use Kotlin-friendly okhttp 2.x implementation("com.squareup.okio:okio:2.+") api("com.squareup.okhttp3:okhttp:${Libs.okhttpVersion}") implementation("org.apache.commons:commons-lang3:3.9") api("org.ogce:xpp3:${Libs.xpp3Version}") testImplementation("com.squareup.okhttp3:mockwebserver") testImplementation("com.squareup.okhttp3:mockwebserver:${Libs.okhttpVersion}") } buildConfigKotlin { Loading
src/main/kotlin/at/bitfire/dav4jvm/BasicDigestAuthHandler.kt +14 −14 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ class BasicDigestAuthHandler( domain?.let { val host = request.url.host if (!domain.equals(UrlUtils.hostToDomain(host), true)) { Constants.log.warning("Not authenticating against $host because it doesn't belong to $domain") Dav4jvm.log.warning("Not authenticating against $host because it doesn't belong to $domain") return null } } Loading @@ -69,7 +69,7 @@ class BasicDigestAuthHandler( // we're not processing a 401 response if (basicAuth == null && digestAuth == null && request.isHttps) { Constants.log.fine("Trying Basic auth preemptively") Dav4jvm.log.fine("Trying Basic auth preemptively") basicAuth = Challenge("Basic", "") } Loading @@ -82,7 +82,7 @@ class BasicDigestAuthHandler( when { "Basic".equals(challenge.scheme, true) -> { basicAuth?.let { Constants.log.warning("Basic credentials didn't work last time -> aborting") Dav4jvm.log.warning("Basic credentials didn't work last time -> aborting") basicAuth = null return null } Loading @@ -90,7 +90,7 @@ class BasicDigestAuthHandler( } "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") Dav4jvm.log.warning("Digest credentials didn't work last time and server nonce has not expired -> aborting") digestAuth = null return null } Loading @@ -105,12 +105,12 @@ class BasicDigestAuthHandler( // we MUST prefer Digest auth [https://tools.ietf.org/html/rfc2617#section-4.6] when { digestAuth != null -> { Constants.log.fine("Adding Digest authorization request for ${request.url}") Dav4jvm.log.fine("Adding Digest authorization request for ${request.url}") return digestRequest(request, digestAuth) } basicAuth != null -> { Constants.log.fine("Adding Basic authorization header for ${request.url}") Dav4jvm.log.fine("Adding Basic authorization header for ${request.url}") /* In RFC 2617 (obsolete), there was no encoding for credentials defined, although one can interpret it as "use ISO-8859-1 encoding". This has been clarified by RFC 7617, Loading @@ -123,7 +123,7 @@ class BasicDigestAuthHandler( } response != null -> Constants.log.warning("No supported authentication scheme") Dav4jvm.log.warning("No supported authentication scheme") } return null Loading @@ -148,13 +148,13 @@ class BasicDigestAuthHandler( if (realm != null) params.add("realm=${quotedString(realm)}") else { Constants.log.warning("No realm provided, aborting Digest auth") Dav4jvm.log.warning("No realm provided, aborting Digest auth") return null } if (nonce != null) params.add("nonce=${quotedString(nonce)}") else { Constants.log.warning("No nonce provided, aborting Digest auth") Dav4jvm.log.warning("No nonce provided, aborting Digest auth") return null } if (opaque != null) Loading Loading @@ -183,7 +183,7 @@ class BasicDigestAuthHandler( else -> null } Constants.log.finer("A1=$a1") Dav4jvm.log.finer("A1=$a1") val a2: String? = when (qop) { Protection.Auth -> Loading @@ -193,18 +193,18 @@ class BasicDigestAuthHandler( val body = request.body "$method:$digestURI:" + (if (body != null) h(body) else h("")) } catch(e: IOException) { Constants.log.warning("Couldn't get entity-body for hash calculation") Dav4jvm.log.warning("Couldn't get entity-body for hash calculation") null } } } Constants.log.finer("A2=$a2") Dav4jvm.log.finer("A2=$a2") if (a1 != null && a2 != null) response = kd(h(a1), "$nonce:$ncValue:$clientNonce:${qop.qop}:${h(a2)}") } else { Constants.log.finer("Using legacy Digest auth") Dav4jvm.log.finer("Using legacy Digest auth") // legacy (backwards compatibility with RFC 2069) if (algorithm == Algorithm.MD5) { Loading Loading @@ -238,7 +238,7 @@ class BasicDigestAuthHandler( MD5_SESSION.algorithm.equals(paramValue, true) -> MD5_SESSION else -> { Constants.log.warning("Ignoring unknown hash algorithm: $paramValue") Dav4jvm.log.warning("Ignoring unknown hash algorithm: $paramValue") null } } Loading
src/main/kotlin/at/bitfire/dav4jvm/Constants.kt→src/main/kotlin/at/bitfire/dav4jvm/Dav4jvm.kt +1 −4 Original line number Diff line number Diff line Loading @@ -6,13 +6,10 @@ package at.bitfire.dav4jvm import BuildConfig import java.util.logging.Logger object Constants { object Dav4jvm { var log = Logger.getLogger("dav4jvm")!! const val okhttpVersion = BuildConfig.okhttpVersion }
src/main/kotlin/at/bitfire/dav4jvm/DavAddressBook.kt +1 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ import java.util.logging.Logger class DavAddressBook @JvmOverloads constructor( httpClient: OkHttpClient, location: HttpUrl, log: Logger = Constants.log log: Logger = Dav4jvm.log ): DavCollection(httpClient, location, log) { companion object { Loading