NTP-58479 | Update token validity check to 90% of expiry (#16224)
This commit is contained in:
@@ -7,10 +7,12 @@
|
||||
|
||||
package com.navi.pay.npcicl
|
||||
|
||||
import com.navi.base.utils.TrustedTimeAccessor
|
||||
import com.navi.pay.common.repository.SharedPreferenceRepository
|
||||
import com.navi.pay.utils.KEY_NPCI_TOKEN
|
||||
import com.navi.pay.utils.KEY_NPCI_TOKEN_EXPIRY_IN_DAYS
|
||||
import com.navi.pay.utils.KEY_NPCI_TOKEN_STORED_TIME
|
||||
import com.navi.pay.utils.ONE_DAY_MILLIS
|
||||
import javax.inject.Inject
|
||||
|
||||
interface NpciSessionHandler {
|
||||
@@ -49,8 +51,10 @@ constructor(private val sharedPreferenceRepository: SharedPreferenceRepository)
|
||||
)
|
||||
return false
|
||||
|
||||
val tokenValidityInMillis = expiryInDays * 1000L * 60 * 60 * 24
|
||||
return System.currentTimeMillis() - tokenTimestamp < tokenValidityInMillis
|
||||
val tokenValidityInMillis = expiryInDays * ONE_DAY_MILLIS
|
||||
val elapsedTime = TrustedTimeAccessor.getCurrentTimeMillis() - tokenTimestamp
|
||||
val thresholdValidity = (tokenValidityInMillis * 0.9).toLong()
|
||||
return elapsedTime < thresholdValidity
|
||||
}
|
||||
|
||||
override suspend fun getChallengeType(): String {
|
||||
@@ -72,7 +76,7 @@ constructor(private val sharedPreferenceRepository: SharedPreferenceRepository)
|
||||
)
|
||||
sharedPreferenceRepository.saveStringValueSynchronously(
|
||||
key = KEY_NPCI_TOKEN_STORED_TIME,
|
||||
value = System.currentTimeMillis().toString(),
|
||||
value = TrustedTimeAccessor.getCurrentTimeMillis().toString(),
|
||||
encrypt = true,
|
||||
)
|
||||
sharedPreferenceRepository.saveStringValueSynchronously(
|
||||
|
||||
@@ -255,7 +255,7 @@ const val CHECK_BALANCE_ERROR_TRANSITION_TOTAL_DURATION: Long =
|
||||
const val LOW_BALANCE = "LowBalance"
|
||||
const val ACTIVATE = "Activate"
|
||||
const val COIN_IMAGE_MAPPING_ID = "imageId"
|
||||
const val ONE_DAY_MILLIS = 24 * 60 * 60 * 1000
|
||||
const val ONE_DAY_MILLIS = 24 * 60 * 60 * 1000L
|
||||
const val DENY = "DENY"
|
||||
const val ALLOW = "ALLOW"
|
||||
const val OTP_AUTO_READ_TIMEOUT_IN_SECONDS = 30
|
||||
|
||||
Reference in New Issue
Block a user