Skip to content

Commit cec383f

Browse files
committed
Change in the clearAPICredentials method signature
1 parent 0c48c23 commit cec383f

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

auth0/src/main/java/com/auth0/android/authentication/storage/BaseCredentialsManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public abstract class BaseCredentialsManager internal constructor(
146146
public abstract val userProfile: UserProfile?
147147

148148
public abstract fun clearCredentials()
149-
public abstract fun clearApiCredentials(audience: String)
149+
public abstract fun clearApiCredentials(audience: String, scope: String? = null)
150150
public abstract fun hasValidCredentials(): Boolean
151151
public abstract fun hasValidCredentials(minTtl: Long): Boolean
152152

auth0/src/main/java/com/auth0/android/authentication/storage/CredentialsManager.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,8 +718,9 @@ public class CredentialsManager @VisibleForTesting(otherwise = VisibleForTesting
718718
/**
719719
* Removes the credentials for the given audience from the storage if present.
720720
*/
721-
override fun clearApiCredentials(audience: String) {
722-
storage.remove(audience)
721+
override fun clearApiCredentials(audience: String, scope: String?) {
722+
val key = getAPICredentialsKey(audience, scope)
723+
storage.remove(key)
723724
Log.d(TAG, "API Credentials for $audience were just removed from the storage")
724725
}
725726

auth0/src/main/java/com/auth0/android/authentication/storage/SecureCredentialsManager.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public class SecureCredentialsManager @VisibleForTesting(otherwise = VisibleForT
232232
* to use on the next call. We clear any existing credentials so #hasValidCredentials returns
233233
* a true value. Retrying this operation will succeed.
234234
*/
235-
clearApiCredentials(audience)
235+
clearApiCredentials(audience, scope)
236236
throw CredentialsManagerException(
237237
CredentialsManagerException.Code.CRYPTO_EXCEPTION,
238238
e
@@ -780,8 +780,9 @@ public class SecureCredentialsManager @VisibleForTesting(otherwise = VisibleForT
780780
/**
781781
* Removes the credentials for the given audience from the storage if present.
782782
*/
783-
override fun clearApiCredentials(audience: String) {
784-
storage.remove(audience)
783+
override fun clearApiCredentials(audience: String, scope: String?) {
784+
val key = getAPICredentialsKey(audience, scope)
785+
storage.remove(key)
785786
Log.d(TAG, "API Credentials for $audience were just removed from the storage")
786787
}
787788

@@ -994,8 +995,7 @@ public class SecureCredentialsManager @VisibleForTesting(otherwise = VisibleForT
994995
)
995996
return@execute
996997
} catch (e: CryptoException) {
997-
//If keys were invalidated, existing credentials will not be recoverable.
998-
clearApiCredentials(audience)
998+
clearApiCredentials(audience, scope)
999999
callback.onFailure(
10001000
CredentialsManagerException(
10011001
CredentialsManagerException.Code.CRYPTO_EXCEPTION,

0 commit comments

Comments
 (0)