mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-26 03:32:39 +03:00
consider not touching YK as cancellation
This commit is contained in:
parent
38a2a852e0
commit
bf9b85f069
@ -15,6 +15,7 @@ import com.yubico.yubikit.core.Transport
|
||||
import com.yubico.yubikit.core.YubiKeyDevice
|
||||
import com.yubico.yubikit.core.YubiKeyType
|
||||
import com.yubico.yubikit.core.application.ApplicationNotAvailableException
|
||||
import com.yubico.yubikit.core.smartcard.ApduException
|
||||
import com.yubico.yubikit.core.smartcard.SmartCardConnection
|
||||
import com.yubico.yubikit.core.util.Result
|
||||
import com.yubico.yubikit.oath.*
|
||||
@ -461,10 +462,19 @@ class OathManager(
|
||||
): Code {
|
||||
// Manual calculate, need to pad timer to avoid immediate expiration
|
||||
val timestamp = System.currentTimeMillis() + 10000
|
||||
return if (credential.isSteamCredential()) {
|
||||
session.calculateSteamCode(credential, timestamp)
|
||||
} else {
|
||||
session.calculateCode(credential, timestamp)
|
||||
try {
|
||||
return if (credential.isSteamCredential()) {
|
||||
session.calculateSteamCode(credential, timestamp)
|
||||
} else {
|
||||
session.calculateCode(credential, timestamp)
|
||||
}
|
||||
} catch (apduException: ApduException) {
|
||||
if (credential.isTouchRequired && apduException.sw.toInt() == 0x6982) {
|
||||
// the most probable reason for this exception
|
||||
// is that the user did not touch the key
|
||||
throw CancellationException()
|
||||
}
|
||||
throw apduException
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user