mirror of
https://github.com/etesync/android
synced 2025-02-22 20:42:04 +00:00
Login credentials: keep the default uri (even if null).
We need this for etebase compat.
This commit is contained in:
parent
65861b3f1c
commit
ee8c8d8fe1
@ -13,6 +13,7 @@ import com.etesync.journalmanager.Crypto
|
||||
import com.etesync.journalmanager.Exceptions
|
||||
import com.etesync.journalmanager.JournalAuthenticator
|
||||
import com.etesync.journalmanager.UserInfoManager
|
||||
import com.etesync.syncadapter.Constants
|
||||
import com.etesync.syncadapter.log.Logger
|
||||
import com.etesync.syncadapter.model.CollectionInfo
|
||||
import okhttp3.HttpUrl
|
||||
@ -36,15 +37,17 @@ class BaseConfigurationFinder(protected val context: Context, protected val cred
|
||||
val cardDavConfig = findInitialConfiguration(CollectionInfo.Type.ADDRESS_BOOK)
|
||||
val calDavConfig = findInitialConfiguration(CollectionInfo.Type.CALENDAR)
|
||||
|
||||
val authenticator = JournalAuthenticator(httpClient, credentials.uri?.toHttpUrlOrNull()!!)
|
||||
val uri = credentials.uri ?: URI(Constants.serviceUrl.toString())
|
||||
|
||||
val authenticator = JournalAuthenticator(httpClient, uri.toHttpUrlOrNull()!!)
|
||||
|
||||
var authtoken: String? = null
|
||||
var userInfo: UserInfoManager.UserInfo? = null
|
||||
try {
|
||||
authtoken = authenticator.getAuthToken(credentials.userName, credentials.password)
|
||||
|
||||
val authenticatedHttpClient = HttpClient.Builder(context, credentials.uri.host, authtoken!!).build().okHttpClient
|
||||
val userInfoManager = UserInfoManager(authenticatedHttpClient, credentials.uri.toHttpUrlOrNull()!!)
|
||||
val authenticatedHttpClient = HttpClient.Builder(context, uri.host, authtoken!!).build().okHttpClient
|
||||
val userInfoManager = UserInfoManager(authenticatedHttpClient, uri.toHttpUrlOrNull()!!)
|
||||
userInfo = userInfoManager.fetch(credentials.userName)
|
||||
} catch (e: Exceptions.HttpException) {
|
||||
Logger.log.warning(e.message)
|
||||
@ -55,7 +58,7 @@ class BaseConfigurationFinder(protected val context: Context, protected val cred
|
||||
}
|
||||
|
||||
return Configuration(
|
||||
credentials.uri,
|
||||
uri,
|
||||
credentials.userName, authtoken,
|
||||
cardDavConfig, calDavConfig,
|
||||
userInfo,
|
||||
|
@ -15,22 +15,7 @@ import com.etesync.syncadapter.log.Logger
|
||||
import java.net.URI
|
||||
import java.net.URISyntaxException
|
||||
|
||||
class LoginCredentials(_uri: URI?, val userName: String, val password: String) : Parcelable {
|
||||
val uri: URI?
|
||||
|
||||
init {
|
||||
var uri = _uri
|
||||
|
||||
if (uri == null) {
|
||||
try {
|
||||
uri = URI(Constants.serviceUrl.toString())
|
||||
} catch (e: URISyntaxException) {
|
||||
Logger.log.severe("Should never happen, it's a constant")
|
||||
}
|
||||
|
||||
}
|
||||
this.uri = uri
|
||||
}
|
||||
class LoginCredentials(val uri: URI?, val userName: String, val password: String) : Parcelable {
|
||||
|
||||
override fun describeContents(): Int {
|
||||
return 0
|
||||
|
Loading…
Reference in New Issue
Block a user