@@ -2,12 +2,11 @@ package com.auth0.android.authentication.storage
22
33import android.text.TextUtils
44import androidx.annotation.VisibleForTesting
5- import com.auth0.android.annotation.ExperimentalAuth0Api
65import com.auth0.android.authentication.AuthenticationAPIClient
76import com.auth0.android.authentication.AuthenticationException
87import com.auth0.android.callback.Callback
98import com.auth0.android.result.Credentials
10- import com.auth0.android.result.SSOCredentials
9+ import com.auth0.android.result.SessionTransferCredentials
1110import kotlinx.coroutines.suspendCancellableCoroutine
1211import java.util.*
1312import java.util.concurrent.Executor
@@ -56,26 +55,22 @@ public class CredentialsManager @VisibleForTesting(otherwise = VisibleForTesting
5655 }
5756
5857 /* *
59- * Fetches a new [SSOCredentials ] . It will fail with [CredentialsManagerException]
58+ * Fetches a new [SessionTransferCredentials ] . It will fail with [CredentialsManagerException]
6059 * if the existing refresh_token is null or no longer valid. This method will handle saving the refresh_token,
6160 * if a new one is issued.
62- * This is still an experimental feature, test it thoroughly and let us know your feedback.
6361 */
64- @ExperimentalAuth0Api
65- override fun getSsoCredentials (callback : Callback <SSOCredentials , CredentialsManagerException >) {
66- getSsoCredentials(emptyMap(), callback)
62+ override fun getSessionTransferCredentials (callback : Callback <SessionTransferCredentials , CredentialsManagerException >) {
63+ getSessionTransferCredentials(emptyMap(), callback)
6764 }
6865
6966 /* *
70- * Fetches a new [SSOCredentials ] . It will fail with [CredentialsManagerException]
67+ * Fetches a new [SessionTransferCredentials ] . It will fail with [CredentialsManagerException]
7168 * if the existing refresh_token is null or no longer valid. This method will handle saving the refresh_token,
7269 * if a new one is issued.
73- * This is still an experimental feature, test it thoroughly and let us know your feedback.
7470 */
75- @ExperimentalAuth0Api
76- override fun getSsoCredentials (
71+ override fun getSessionTransferCredentials (
7772 parameters : Map <String , String >,
78- callback : Callback <SSOCredentials , CredentialsManagerException >
73+ callback : Callback <SessionTransferCredentials , CredentialsManagerException >
7974 ) {
8075 serialExecutor.execute {
8176 val refreshToken = storage.retrieveString(KEY_REFRESH_TOKEN )
@@ -84,14 +79,14 @@ public class CredentialsManager @VisibleForTesting(otherwise = VisibleForTesting
8479 return @execute
8580 }
8681
87- val request = authenticationClient.fetchWebSsoToken (refreshToken)
82+ val request = authenticationClient.fetchSessionTransferToken (refreshToken)
8883 try {
8984 if (parameters.isNotEmpty()) {
9085 request.addParameters(parameters)
9186 }
92- val sessionCredentials = request.execute()
93- saveSsoCredentials(sessionCredentials )
94- callback.onSuccess(sessionCredentials )
87+ val sessionTransferCredentials = request.execute()
88+ saveSessionTransferCredentials(sessionTransferCredentials )
89+ callback.onSuccess(sessionTransferCredentials )
9590 } catch (error: AuthenticationException ) {
9691 val exception = when {
9792 error.isRefreshTokenDeleted ||
@@ -111,32 +106,29 @@ public class CredentialsManager @VisibleForTesting(otherwise = VisibleForTesting
111106 }
112107
113108 /* *
114- * Fetches a new [SSOCredentials ] . It will fail with [CredentialsManagerException]
109+ * Fetches a new [SessionTransferCredentials ] . It will fail with [CredentialsManagerException]
115110 * if the existing refresh_token is null or no longer valid. This method will handle saving the refresh_token,
116111 * if a new one is issued.
117- * This is still an experimental feature, test it thoroughly and OS variants and let us know your feedback.
118112 */
119113 @JvmSynthetic
120114 @Throws(CredentialsManagerException ::class )
121- @ExperimentalAuth0Api
122- override suspend fun awaitSsoCredentials (): SSOCredentials {
123- return awaitSsoCredentials(emptyMap())
115+ override suspend fun awaitSessionTransferCredentials (): SessionTransferCredentials {
116+ return awaitSessionTransferCredentials(emptyMap())
124117 }
125118
126119 /* *
127- * Fetches a new [SSOCredentials ] . It will fail with [CredentialsManagerException]
120+ * Fetches a new [SessionTransferCredentials ] . It will fail with [CredentialsManagerException]
128121 * if the existing refresh_token is null or no longer valid. This method will handle saving the refresh_token,
129122 * if a new one is issued.
130- * This is still an experimental feature, test it thoroughly and OS variants and let us know your feedback.
131123 */
132124 @JvmSynthetic
133125 @Throws(CredentialsManagerException ::class )
134- @ExperimentalAuth0Api
135- override suspend fun awaitSsoCredentials (parameters : Map <String , String >): SSOCredentials {
126+ override suspend fun awaitSessionTransferCredentials (parameters : Map <String , String >): SessionTransferCredentials {
136127 return suspendCancellableCoroutine { continuation ->
137- getSsoCredentials(parameters,
138- object : Callback <SSOCredentials , CredentialsManagerException > {
139- override fun onSuccess (result : SSOCredentials ) {
128+ getSessionTransferCredentials(
129+ parameters,
130+ object : Callback <SessionTransferCredentials , CredentialsManagerException > {
131+ override fun onSuccess (result : SessionTransferCredentials ) {
140132 continuation.resume(result)
141133 }
142134
@@ -238,7 +230,8 @@ public class CredentialsManager @VisibleForTesting(otherwise = VisibleForTesting
238230 forceRefresh : Boolean
239231 ): Credentials {
240232 return suspendCancellableCoroutine { continuation ->
241- getCredentials(scope,
233+ getCredentials(
234+ scope,
242235 minTtl,
243236 parameters,
244237 headers,
@@ -473,20 +466,21 @@ public class CredentialsManager @VisibleForTesting(otherwise = VisibleForTesting
473466 }
474467
475468 /* *
476- * Helper method to store the given [SSOCredentials ] refresh token in the storage.
469+ * Helper method to store the given [SessionTransferCredentials ] refresh token in the storage.
477470 * Method will silently return ,if the passed credentials has no refresh token.
478471 *
479- * @param ssoCredentials the credentials to save in the storage.
472+ * @param sessionTransferCredentials the credentials to save in the storage.
480473 */
481474 @VisibleForTesting(otherwise = VisibleForTesting .PRIVATE )
482- internal fun saveSsoCredentials (ssoCredentials : SSOCredentials ) {
483- if (ssoCredentials.refreshToken.isNullOrEmpty())
484- return // No refresh token to save
475+ internal fun saveSessionTransferCredentials (sessionTransferCredentials : SessionTransferCredentials ) {
476+ storage.store(KEY_ID_TOKEN , sessionTransferCredentials.idToken)
485477 val existingRefreshToken = storage.retrieveString(KEY_REFRESH_TOKEN )
486478 // Checking if the existing one needs to be replaced with the new one
487- if (ssoCredentials.refreshToken == existingRefreshToken)
479+ if (sessionTransferCredentials.refreshToken.isNullOrEmpty())
480+ return // No refresh token to save
481+ if (sessionTransferCredentials.refreshToken == existingRefreshToken)
488482 return // Same refresh token, no need to save
489- storage.store(KEY_REFRESH_TOKEN , ssoCredentials .refreshToken)
483+ storage.store(KEY_REFRESH_TOKEN , sessionTransferCredentials .refreshToken)
490484 }
491485
492486 @VisibleForTesting(otherwise = VisibleForTesting .PRIVATE )
0 commit comments