Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Digest Auth Support #26

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ dependencies {
implementation "com.mikepenz:aboutlibraries-core:$aboutLibrariesVersion"
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0'
implementation 'io.github.rburgst:okhttp-digest:3.1.0'
implementation 'com.squareup.retrofit2:retrofit:2.11.0'
implementation 'com.squareup.retrofit2:converter-simplexml:2.11.0'
implementation 'com.github.thegrizzlylabs:sardine-android:0.9'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ package dev.rocli.android.webdav.provider
import android.annotation.SuppressLint
import android.content.Context
import android.security.KeyChain
import com.burgstaller.okhttp.AuthenticationCacheInterceptor
import com.burgstaller.okhttp.CachingAuthenticatorDecorator
import com.burgstaller.okhttp.digest.CachingAuthenticator
import com.burgstaller.okhttp.digest.DigestAuthenticator
import com.thegrizzlylabs.sardineandroid.model.Prop
import com.thegrizzlylabs.sardineandroid.model.Property
import com.thegrizzlylabs.sardineandroid.model.Resourcetype
Expand Down Expand Up @@ -30,6 +34,7 @@ import java.security.Principal
import java.security.PrivateKey
import java.security.SecureRandom
import java.security.cert.X509Certificate
import java.util.concurrent.ConcurrentHashMap
import javax.net.ssl.KeyManager
import javax.net.ssl.SSLContext
import javax.net.ssl.TrustManager
Expand Down Expand Up @@ -233,8 +238,18 @@ class WebDavClient(
builder.addInterceptor(logging)
}
if (creds != null) {

// Basic Auth (Default)
val auth = Credentials.basic(creds.first, creds.second)
builder.addInterceptor(AuthInterceptor(auth))

// Digest Auth Support
val authenticator = DigestAuthenticator(com.burgstaller.okhttp.digest.Credentials(creds.first, creds.second))
val authCache: Map<String, CachingAuthenticator> = ConcurrentHashMap<String, CachingAuthenticator>()

builder.authenticator(CachingAuthenticatorDecorator(authenticator, authCache))
builder.addInterceptor(AuthenticationCacheInterceptor(authCache))

}

val serializer = buildSerializer()
Expand Down
8 changes: 8 additions & 0 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2787,6 +2787,14 @@
<sha512 value="75bef548eea62ab04569791f2fdeed3d0a61edae0534aa035a905dc1d011988fc0f06f52bde377f44e94e6afd4380197148120b152b7a4d20628fb6236cc7261" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="io.github.rburgst" name="okhttp-digest" version="3.1.0">
<artifact name="okhttp-digest-3.1.0.jar">
<sha512 value="3a05e91482da99e20cc97a0673d5ff444818aa0ec21f22d6d2a97298d37de82506bd185bd6d1c485c60f3e3ef905a596923264f5e69ad3a91eb0b62caad279fd" origin="Generated by Gradle"/>
</artifact>
<artifact name="okhttp-digest-3.1.0.module">
<sha512 value="a6d1d1260c8dd2fa41a9777770b1a2a8372381d8987d0c7b0c6380e9bbbf3724ed3381594eb95b02f9eb6d834e138ab14d0e61347651d6a62e2094f1bd4077fa" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="io.grpc" name="grpc-api" version="1.57.0">
<artifact name="grpc-api-1.57.0.jar">
<sha512 value="5824f05b82b83bf815c8d8499a620246622f9889308c1bbba1378e6ff17e0fb5eec7327c57d96a8e4cef74d089d7354265bfa0f5db04d0bbf856efa29c414f5b" origin="Generated by Gradle"/>
Expand Down