Skip to content

Commit 5875c0c

Browse files
committed
Addressed review comments
1 parent 3283ad2 commit 5875c0c

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,21 @@ public abstract class BaseCredentialsManager internal constructor(
170170
protected fun saveDPoPThumbprint(credentials: Credentials) {
171171
val dpopUsed = credentials.type.equals("DPoP", ignoreCase = true)
172172
|| authenticationClient.isDPoPEnabled
173-
if (dpopUsed && DPoPUtil.hasKeyPair()) {
174-
try {
175-
val thumbprint = DPoPUtil.getPublicKeyJWK()
176-
if (thumbprint != null) {
177-
storage.store(KEY_DPOP_THUMBPRINT, thumbprint)
178-
}
179-
} catch (e: DPoPException) {
180-
Log.w(this::class.java.simpleName, "Failed to store DPoP key thumbprint", e)
181-
}
173+
174+
if (!dpopUsed) {
175+
storage.remove(KEY_DPOP_THUMBPRINT)
176+
return
177+
}
178+
179+
val thumbprint = try {
180+
if (DPoPUtil.hasKeyPair()) DPoPUtil.getPublicKeyJWK() else null
181+
} catch (e: DPoPException) {
182+
Log.w(this::class.java.simpleName, "Failed to fetch DPoP key thumbprint", e)
183+
null
184+
}
185+
186+
if (thumbprint != null) {
187+
storage.store(KEY_DPOP_THUMBPRINT, thumbprint)
182188
} else {
183189
storage.remove(KEY_DPOP_THUMBPRINT)
184190
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public class CredentialsManagerException :
215215
Code.SSO_EXCHANGE_FAILED ->"The exchange of the refresh token for SSO credentials failed."
216216
Code.MFA_REQUIRED -> "Multi-factor authentication is required to complete the credential renewal."
217217
Code.DPOP_KEY_MISSING -> "The stored credentials are DPoP-bound but the DPoP key pair is no longer available in the Android KeyStore. Re-authentication is required."
218-
Code.DPOP_NOT_CONFIGURED -> "The stored credentials are DPoP-bound but the AuthenticationAPIClient used by this CredentialsManager was not configured with useDPoP(context). Call AuthenticationAPIClient(auth0).useDPoP(context) and pass the configured client to CredentialsManager."
218+
Code.DPOP_NOT_CONFIGURED -> "The stored credentials are DPoP-bound but the AuthenticationAPIClient used by this credentials manager was not configured with useDPoP(context). Call AuthenticationAPIClient(auth0).useDPoP(context) and pass the configured client to the credentials manager."
219219
Code.UNKNOWN_ERROR -> "An unknown error has occurred while fetching the token. Please check the error cause for more details."
220220
}
221221
}

0 commit comments

Comments
 (0)