Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Commit

Permalink
Merge pull request #85 from admin-ch/bugfix/invalid-state-renew-banne…
Browse files Browse the repository at this point in the history
…r-check

Move showRenewBanner checks
  • Loading branch information
benz-ubique authored Jun 20, 2022
2 parents 93ff1fc + d69f3f1 commit d951f5c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

package ch.admin.bag.covidcertificate.sdk.core.models.state

import ch.admin.bag.covidcertificate.sdk.core.data.ErrorCodes
import ch.admin.bag.covidcertificate.sdk.core.verifier.nationalrules.NationalRulesError
import ch.admin.bag.covidcertificate.sdk.core.verifier.nationalrules.ValidityRange

Expand Down Expand Up @@ -53,14 +52,7 @@ sealed class CheckNationalRulesState {
else -> null
}

fun showRenewBanner(checkSignatureState: CheckSignatureState, checkRevocationState: CheckRevocationState): String? {
if (checkSignatureState is CheckSignatureState.INVALID && checkSignatureState.signatureErrorCode != ErrorCodes.SIGNATURE_TIMESTAMP_EXPIRED) {
return null
}
if (checkRevocationState is CheckRevocationState.INVALID) {
return null
}

fun showRenewBanner(): String? {
return when (this) {
is SUCCESS -> showRenewBanner
is NOT_YET_VALID -> showRenewBanner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,24 @@
package ch.admin.bag.covidcertificate.sdk.core.verifier

import ch.admin.bag.covidcertificate.sdk.core.data.ErrorCodes
import ch.admin.bag.covidcertificate.sdk.core.decoder.chain.*
import ch.admin.bag.covidcertificate.sdk.core.decoder.chain.Base45Service
import ch.admin.bag.covidcertificate.sdk.core.decoder.chain.DecompressionService
import ch.admin.bag.covidcertificate.sdk.core.decoder.chain.PrefixIdentifierService
import ch.admin.bag.covidcertificate.sdk.core.decoder.chain.RevokedHealthCertService
import ch.admin.bag.covidcertificate.sdk.core.decoder.chain.TimestampService
import ch.admin.bag.covidcertificate.sdk.core.decoder.chain.VerificationCoseService
import ch.admin.bag.covidcertificate.sdk.core.models.certlogic.CertLogicHeaders
import ch.admin.bag.covidcertificate.sdk.core.models.healthcert.CertType
import ch.admin.bag.covidcertificate.sdk.core.models.healthcert.CertificateHolder
import ch.admin.bag.covidcertificate.sdk.core.models.healthcert.eu.DccCert
import ch.admin.bag.covidcertificate.sdk.core.models.state.*
import ch.admin.bag.covidcertificate.sdk.core.models.state.CheckModeRulesState
import ch.admin.bag.covidcertificate.sdk.core.models.state.CheckNationalRulesState
import ch.admin.bag.covidcertificate.sdk.core.models.state.CheckRevocationState
import ch.admin.bag.covidcertificate.sdk.core.models.state.CheckSignatureState
import ch.admin.bag.covidcertificate.sdk.core.models.state.ModeValidity
import ch.admin.bag.covidcertificate.sdk.core.models.state.StateError
import ch.admin.bag.covidcertificate.sdk.core.models.state.SuccessState
import ch.admin.bag.covidcertificate.sdk.core.models.state.VerificationState
import ch.admin.bag.covidcertificate.sdk.core.models.trustlist.Jwks
import ch.admin.bag.covidcertificate.sdk.core.models.trustlist.RevokedCertificatesStore
import ch.admin.bag.covidcertificate.sdk.core.models.trustlist.RuleSet
Expand Down Expand Up @@ -111,12 +123,21 @@ class CertificateVerifier {
|| checkNationalRulesState is CheckNationalRulesState.NOT_YET_VALID
|| checkNationalRulesState is CheckNationalRulesState.NOT_VALID_ANYMORE
) {
val showRenewBanner = if (
(checkSignatureState is CheckSignatureState.INVALID && checkSignatureState.signatureErrorCode != ErrorCodes.SIGNATURE_TIMESTAMP_EXPIRED)
|| checkRevocationState is CheckRevocationState.INVALID
) {
null
} else {
checkNationalRulesState.showRenewBanner()
}

VerificationState.INVALID(
checkSignatureState,
checkRevocationState,
checkNationalRulesState,
checkNationalRulesState.validityRange(),
checkNationalRulesState.showRenewBanner(checkSignatureState, checkRevocationState)
showRenewBanner
)
} else {
VerificationState.LOADING
Expand Down

0 comments on commit d951f5c

Please sign in to comment.