handle locked oath sessions when refreshing

This commit is contained in:
Adam Velebil 2022-11-21 09:39:47 +01:00
parent d753c43a6a
commit 3bc8304f34

View File

@ -444,9 +444,22 @@ class OathManager(
private suspend fun requestRefresh() =
appViewModel.connectedYubiKey.value?.let { usbYubiKeyDevice ->
useOathSessionUsb(usbYubiKeyDevice) { session ->
try {
oathViewModel.updateCredentials(
calculateOathCodes(session).model(session.deviceId)
)
} catch(apduException: ApduException) {
if (apduException.sw == SW.SECURITY_CONDITION_NOT_SATISFIED) {
Log.d(TAG, "Handled oath credential refresh on locked session.")
oathViewModel.setSessionState(session.model(keyManager.isRemembered(session.deviceId)))
} else {
Log.e(
TAG,
"Unexpected sw when refreshing oath credentials",
apduException.message
)
}
}
}
}