mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 03:18:06 +00:00
Using OpenID library fetchFromIssuer instead of handling well-known manually
This commit is contained in:
parent
ccd53b74db
commit
10b7545807
1 changed files with 7 additions and 17 deletions
|
|
@ -47,7 +47,6 @@ class SingleSignOnViewModel : GenericViewModel() {
|
|||
|
||||
private const val CLIENT_ID = "linphone"
|
||||
private const val REDIRECT_URI = "org.linphone:/openidcallback"
|
||||
private const val OPEN_ID_WELL_KNOWN = ".well-known/openid-configuration"
|
||||
}
|
||||
|
||||
val singleSignOnProcessCompletedEvent = MutableLiveData<Event<Boolean>>()
|
||||
|
|
@ -99,27 +98,18 @@ class SingleSignOnViewModel : GenericViewModel() {
|
|||
|
||||
@UiThread
|
||||
private fun singleSignOn() {
|
||||
Log.i("$TAG Fetch from issuer")
|
||||
AuthorizationServiceConfiguration.fetchFromUrl(
|
||||
Log.i("$TAG Fetch from issuer [$singleSignOnUrl]")
|
||||
AuthorizationServiceConfiguration.fetchFromIssuer(
|
||||
Uri.parse(singleSignOnUrl),
|
||||
AuthorizationServiceConfiguration.RetrieveConfigurationCallback { serviceConfiguration, ex ->
|
||||
if (ex != null) {
|
||||
Log.e(
|
||||
"$TAG Failed to fetch configuration on [$singleSignOnUrl]: ${ex.errorDescription}"
|
||||
"$TAG Failed to fetch configuration from issuer [$singleSignOnUrl]: ${ex.errorDescription}"
|
||||
)
|
||||
if (!singleSignOnUrl.endsWith(OPEN_ID_WELL_KNOWN)) {
|
||||
Log.w("$TAG Trying again appending [$OPEN_ID_WELL_KNOWN] to URL")
|
||||
singleSignOnUrl = if (singleSignOnUrl.endsWith("/")) {
|
||||
"$singleSignOnUrl$OPEN_ID_WELL_KNOWN"
|
||||
} else {
|
||||
"$singleSignOnUrl/$OPEN_ID_WELL_KNOWN"
|
||||
}
|
||||
singleSignOn()
|
||||
return@RetrieveConfigurationCallback
|
||||
} else {
|
||||
onErrorEvent.postValue(Event("Failed to fetch configuration"))
|
||||
return@RetrieveConfigurationCallback
|
||||
}
|
||||
onErrorEvent.postValue(
|
||||
Event("Failed to fetch configuration from issuer $singleSignOnUrl")
|
||||
)
|
||||
return@RetrieveConfigurationCallback
|
||||
}
|
||||
|
||||
if (serviceConfiguration == null) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue