mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-25 23:14:18 +03:00
Merge PR #233.
This commit is contained in:
commit
dd123adc07
@ -15,6 +15,8 @@ import com.yubico.yubikit.core.Transport
|
|||||||
import com.yubico.yubikit.core.YubiKeyDevice
|
import com.yubico.yubikit.core.YubiKeyDevice
|
||||||
import com.yubico.yubikit.core.YubiKeyType
|
import com.yubico.yubikit.core.YubiKeyType
|
||||||
import com.yubico.yubikit.core.application.ApplicationNotAvailableException
|
import com.yubico.yubikit.core.application.ApplicationNotAvailableException
|
||||||
|
import com.yubico.yubikit.core.smartcard.ApduException
|
||||||
|
import com.yubico.yubikit.core.smartcard.SW
|
||||||
import com.yubico.yubikit.core.smartcard.SmartCardConnection
|
import com.yubico.yubikit.core.smartcard.SmartCardConnection
|
||||||
import com.yubico.yubikit.core.util.Result
|
import com.yubico.yubikit.core.util.Result
|
||||||
import com.yubico.yubikit.oath.*
|
import com.yubico.yubikit.oath.*
|
||||||
@ -39,7 +41,7 @@ class OathManager(
|
|||||||
) : AppContextManager {
|
) : AppContextManager {
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "OathManager"
|
const val TAG = "OathManager"
|
||||||
const val NFC_DATA_CLEANUP_DELAY = 30L * 1000; // 30s
|
const val NFC_DATA_CLEANUP_DELAY = 30L * 1000 // 30s
|
||||||
}
|
}
|
||||||
|
|
||||||
private val dispatcher = Executors.newSingleThreadExecutor().asCoroutineDispatcher()
|
private val dispatcher = Executors.newSingleThreadExecutor().asCoroutineDispatcher()
|
||||||
@ -461,11 +463,20 @@ class OathManager(
|
|||||||
): Code {
|
): Code {
|
||||||
// Manual calculate, need to pad timer to avoid immediate expiration
|
// Manual calculate, need to pad timer to avoid immediate expiration
|
||||||
val timestamp = System.currentTimeMillis() + 10000
|
val timestamp = System.currentTimeMillis() + 10000
|
||||||
|
try {
|
||||||
return if (credential.isSteamCredential()) {
|
return if (credential.isSteamCredential()) {
|
||||||
session.calculateSteamCode(credential, timestamp)
|
session.calculateSteamCode(credential, timestamp)
|
||||||
} else {
|
} else {
|
||||||
session.calculateCode(credential, timestamp)
|
session.calculateCode(credential, timestamp)
|
||||||
}
|
}
|
||||||
|
} catch (apduException: ApduException) {
|
||||||
|
if (credential.isTouchRequired && apduException.sw == SW.SECURITY_CONDITION_NOT_SATISFIED) {
|
||||||
|
// 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