mirror of
https://github.com/bitwarden/android.git
synced 2025-12-10 20:07:59 -06:00
[PM-28352] Add logging to Credential Manager and Origin Manager flows (#6229)
This commit is contained in:
parent
4905358adb
commit
593bfbf8cf
@ -49,6 +49,7 @@ class OriginManagerImpl(
|
|||||||
)
|
)
|
||||||
.fold(
|
.fold(
|
||||||
onSuccess = {
|
onSuccess = {
|
||||||
|
Timber.d("Digital asset link validation result: linked = ${it.linked}")
|
||||||
if (it.linked) {
|
if (it.linked) {
|
||||||
ValidateOriginResult.Success(null)
|
ValidateOriginResult.Success(null)
|
||||||
} else {
|
} else {
|
||||||
@ -56,6 +57,7 @@ class OriginManagerImpl(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onFailure = {
|
onFailure = {
|
||||||
|
Timber.e("Failed to validate origin for calling app")
|
||||||
ValidateOriginResult.Error.AssetLinkNotFound
|
ValidateOriginResult.Error.AssetLinkNotFound
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -105,7 +107,7 @@ class OriginManagerImpl(
|
|||||||
.fold(
|
.fold(
|
||||||
onSuccess = { it },
|
onSuccess = { it },
|
||||||
onFailure = {
|
onFailure = {
|
||||||
Timber.e(it, "Failed to validate privileged app: ${callingAppInfo.packageName}")
|
Timber.e(it, "Failed to validate calling app is privileged.")
|
||||||
ValidateOriginResult.Error.Unknown
|
ValidateOriginResult.Error.Unknown
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
@ -37,6 +37,7 @@ import com.x8bit.bitwarden.data.credentials.model.GetCredentialsRequest
|
|||||||
import com.x8bit.bitwarden.data.platform.manager.BiometricsEncryptionManager
|
import com.x8bit.bitwarden.data.platform.manager.BiometricsEncryptionManager
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import timber.log.Timber
|
||||||
import java.time.Clock
|
import java.time.Clock
|
||||||
import javax.crypto.Cipher
|
import javax.crypto.Cipher
|
||||||
|
|
||||||
@ -63,8 +64,10 @@ class CredentialProviderProcessorImpl(
|
|||||||
cancellationSignal: CancellationSignal,
|
cancellationSignal: CancellationSignal,
|
||||||
callback: OutcomeReceiver<BeginCreateCredentialResponse, CreateCredentialException>,
|
callback: OutcomeReceiver<BeginCreateCredentialResponse, CreateCredentialException>,
|
||||||
) {
|
) {
|
||||||
|
Timber.d("Create credential request received.")
|
||||||
val userId = authRepository.activeUserId
|
val userId = authRepository.activeUserId
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
|
Timber.w("No active user. Cannot create credential.")
|
||||||
callback.onError(CreateCredentialUnknownException("Active user is required."))
|
callback.onError(CreateCredentialUnknownException("Active user is required."))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -72,12 +75,16 @@ class CredentialProviderProcessorImpl(
|
|||||||
val createCredentialJob = ioScope.launch {
|
val createCredentialJob = ioScope.launch {
|
||||||
(handleCreatePasskeyQuery(request) ?: handleCreatePasswordQuery(request))
|
(handleCreatePasskeyQuery(request) ?: handleCreatePasswordQuery(request))
|
||||||
?.let { callback.onResult(it) }
|
?.let { callback.onResult(it) }
|
||||||
?: callback.onError(CreateCredentialUnknownException())
|
?: run {
|
||||||
|
Timber.w("Unknown create credential request.")
|
||||||
|
callback.onError(CreateCredentialUnknownException())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cancellationSignal.setOnCancelListener {
|
cancellationSignal.setOnCancelListener {
|
||||||
if (createCredentialJob.isActive) {
|
if (createCredentialJob.isActive) {
|
||||||
createCredentialJob.cancel()
|
createCredentialJob.cancel()
|
||||||
}
|
}
|
||||||
|
Timber.d("Create credential request cancelled by system.")
|
||||||
callback.onError(CreateCredentialCancellationException())
|
callback.onError(CreateCredentialCancellationException())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,15 +94,18 @@ class CredentialProviderProcessorImpl(
|
|||||||
cancellationSignal: CancellationSignal,
|
cancellationSignal: CancellationSignal,
|
||||||
callback: OutcomeReceiver<BeginGetCredentialResponse, GetCredentialException>,
|
callback: OutcomeReceiver<BeginGetCredentialResponse, GetCredentialException>,
|
||||||
) {
|
) {
|
||||||
|
Timber.d("Get credential request received.")
|
||||||
// If the user is not logged in, return an error.
|
// If the user is not logged in, return an error.
|
||||||
val userState = authRepository.userStateFlow.value
|
val userState = authRepository.userStateFlow.value
|
||||||
if (userState == null) {
|
if (userState == null) {
|
||||||
|
Timber.w("No active user. Cannot get credentials.")
|
||||||
callback.onError(GetCredentialUnknownException("Active user is required."))
|
callback.onError(GetCredentialUnknownException("Active user is required."))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return an unlock action if the current account is locked.
|
// Return an unlock action if the current account is locked.
|
||||||
if (!userState.activeAccount.isVaultUnlocked) {
|
if (!userState.activeAccount.isVaultUnlocked) {
|
||||||
|
Timber.d("Vault is locked. Requesting unlock.")
|
||||||
val authenticationAction = AuthenticationAction(
|
val authenticationAction = AuthenticationAction(
|
||||||
title = context.getString(BitwardenString.unlock),
|
title = context.getString(BitwardenString.unlock),
|
||||||
pendingIntent = pendingIntentManager.createFido2UnlockPendingIntent(
|
pendingIntent = pendingIntentManager.createFido2UnlockPendingIntent(
|
||||||
@ -120,10 +130,17 @@ class CredentialProviderProcessorImpl(
|
|||||||
BeginGetCredentialRequest.asBundle(request),
|
BeginGetCredentialRequest.asBundle(request),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.onSuccess { callback.onResult(BeginGetCredentialResponse(credentialEntries = it)) }
|
.onSuccess {
|
||||||
.onFailure { callback.onError(GetCredentialUnknownException(it.message)) }
|
Timber.d("Credentials retrieved.")
|
||||||
|
callback.onResult(BeginGetCredentialResponse(credentialEntries = it))
|
||||||
|
}
|
||||||
|
.onFailure {
|
||||||
|
Timber.w("Error getting credentials.")
|
||||||
|
callback.onError(GetCredentialUnknownException(it.message))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cancellationSignal.setOnCancelListener {
|
cancellationSignal.setOnCancelListener {
|
||||||
|
Timber.d("Get credential request cancelled by system.")
|
||||||
callback.onError(GetCredentialCancellationException())
|
callback.onError(GetCredentialCancellationException())
|
||||||
getCredentialJob.cancel()
|
getCredentialJob.cancel()
|
||||||
}
|
}
|
||||||
@ -135,6 +152,7 @@ class CredentialProviderProcessorImpl(
|
|||||||
callback: OutcomeReceiver<Void?, ClearCredentialException>,
|
callback: OutcomeReceiver<Void?, ClearCredentialException>,
|
||||||
) {
|
) {
|
||||||
// no-op: RFU
|
// no-op: RFU
|
||||||
|
Timber.w("Unsupported clear credential state request received.")
|
||||||
callback.onError(ClearCredentialUnsupportedException())
|
callback.onError(ClearCredentialUnsupportedException())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user