Skip to content

Commit

Permalink
Updated fields adding to external parameter and to rules (eu-digital-…
Browse files Browse the repository at this point in the history
…green-certificates#118)

* Updated fields adding  to external parameter and  to rules

* Updated fetching of issuing country
  • Loading branch information
oleksandrsarapulovgl authored Jun 29, 2021
1 parent a7e4fd3 commit 90e1ecb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ object EngineModule {
@Singleton
@Provides
fun provideRulesDb(@ApplicationContext context: Context): EngineDatabase =
Room.databaseBuilder(context, EngineDatabase::class.java, "engine-db").build()
Room.databaseBuilder(context, EngineDatabase::class.java, "engine-db")
.fallbackToDestructiveMigration().build()

@Singleton
@Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ object LocalDataSourceModule {
@Singleton
@Provides
fun provideDb(@ApplicationContext context: Context): AppDatabase =
Room.databaseBuilder(context, AppDatabase::class.java, "key-db").build()
Room.databaseBuilder(context, AppDatabase::class.java, "key-db")
.fallbackToDestructiveMigration().build()
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ class VerificationViewModel @Inject constructor(
greenCertificateData = cborService.decodeData(coseData.cbor, verificationResult)
validateCertData(greenCertificateData?.greenCertificate, verificationResult)

val certificates = verifierRepository.getCertificatesBy(kid.toBase64())
val base64EncodedKid = kid.toBase64()
val certificates = verifierRepository.getCertificatesBy(base64EncodedKid)
if (certificates.isEmpty()) {
Timber.d("Verification failed: failed to load certificate")
return@withContext
Expand All @@ -151,8 +152,9 @@ class VerificationViewModel @Inject constructor(
), Type.ACCEPTANCE, this.greenCertificate.getType()
)
)
val issuingCountry = this.greenCertificate.getIssuingCountry()
if (issuingCountry.isNotBlank()) {
val issuingCountry: String? =
if (this.issuingCountry?.isNotBlank() == true) this.issuingCountry else this.greenCertificate.getIssuingCountry()
if (issuingCountry?.isNotBlank() == true) {
rules.addAll(
rulesRepository.getRulesBy(
issuingCountry, ZonedDateTime.now().withZoneSameInstant(
Expand All @@ -171,6 +173,7 @@ class VerificationViewModel @Inject constructor(
}

val externalParameter = ExternalParameter(
base64EncodedKid,
ZonedDateTime.now(ZoneId.of(ZoneOffset.UTC.id)),
valueSetsMap,
countryIsoCode,
Expand Down

0 comments on commit 90e1ecb

Please sign in to comment.