Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Wallet Core 0.12.2, New Logic Storage Module for upcoming caching mechanisms. #243

Merged
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ The released software is an initial development release version:

*core-logic*: Wallet core logic.

*storage-logic*: Persistent storage cache.

*authentication-logic*: Pin/Biometry Storage and System Biometrics Logic.

*ui-logic*: Common UI components.
Expand Down Expand Up @@ -249,6 +251,8 @@ graph TD;
analytics-logic -->ui-logic

business-logic -->network-logic

business-logic -->storage-logic

resources-logic -->business-logic

Expand Down
2 changes: 2 additions & 0 deletions assembly-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import project.convention.logic.config.LibraryModule.PresentationFeature
import project.convention.logic.config.LibraryModule.ProximityFeature
import project.convention.logic.config.LibraryModule.ResourcesLogic
import project.convention.logic.config.LibraryModule.StartupFeature
import project.convention.logic.config.LibraryModule.StorageLogic
import project.convention.logic.config.LibraryModule.UiLogic
import project.convention.logic.kover.KoverExclusionRules
import project.convention.logic.kover.excludeFromKoverReport
Expand Down Expand Up @@ -62,6 +63,7 @@ dependencies {
api(project(AnalyticsLogic.path))
api(project(AuthenticationLogic.path))
api(project(CoreLogic.path))
api(project(StorageLogic.path))

// Feature Modules
api(project(CommonFeature.path))
Expand Down
2 changes: 1 addition & 1 deletion assembly-logic/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
</provider>

<service
android:name="eu.europa.ec.eudi.wallet.util.DefaultNfcEngagementService"
android:name="eu.europa.ec.corelogic.service.NfcEngagementService"
android:exported="true"
android:label="@string/nfc_engagement_service_desc"
android:permission="android.permission.BIND_NFC_SERVICE">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,19 @@ import android.app.Application
import eu.europa.ec.analyticslogic.controller.AnalyticsController
import eu.europa.ec.assemblylogic.di.setupKoin
import eu.europa.ec.businesslogic.config.ConfigLogic
import eu.europa.ec.corelogic.config.WalletCoreConfig
import eu.europa.ec.eudi.rqesui.infrastructure.EudiRQESUi
import eu.europa.ec.eudi.wallet.EudiWallet
import org.koin.android.ext.android.inject
import org.koin.core.KoinApplication

class Application : Application() {

private val configWalletCore: WalletCoreConfig by inject()
private val analyticsController: AnalyticsController by inject()
private val configLogic: ConfigLogic by inject()

override fun onCreate() {
super.onCreate()
initializeKoin().initializeRqes()
initializeReporting()
initializeEudiWallet()
}

private fun KoinApplication.initializeRqes() {
Expand All @@ -54,11 +50,4 @@ class Application : Application() {
private fun initializeReporting() {
analyticsController.initialize(this)
}

private fun initializeEudiWallet() {
EudiWallet.init(
applicationContext,
configWalletCore.config
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import eu.europa.ec.presentationfeature.di.FeaturePresentationModule
import eu.europa.ec.proximityfeature.di.FeatureProximityModule
import eu.europa.ec.resourceslogic.di.LogicResourceModule
import eu.europa.ec.startupfeature.di.FeatureStartupModule
import eu.europa.ec.storagelogic.di.LogicStorageModule
import eu.europa.ec.uilogic.di.LogicUiModule
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
Expand All @@ -47,6 +48,7 @@ private val assembledModules = listOf(
LogicAnalyticsModule().module,
LogicAuthenticationModule().module,
LogicCoreModule().module,
LogicStorageModule().module,

// Feature Modules
FeatureCommonModule().module,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class DeviceAuthenticationControllerImpl(
}

data class DeviceAuthenticationResult(
val onAuthenticationSuccess: () -> Unit = {},
val onAuthenticationSuccess: suspend () -> Unit = {},
val onAuthenticationError: () -> Unit = {},
val onAuthenticationFailure: () -> Unit = {},
)
4 changes: 4 additions & 0 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,9 @@ gradlePlugin {
id = "project.rqes.sdk"
implementationClass = "EudiRqesPlugin"
}
register("kotlinRealm") {
id = "project.kotlin.realm"
implementationClass = "RealmPlugin"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class AndroidFeatureConventionPlugin : Plugin<Project> {
add("implementation", project(LibraryModule.AnalyticsLogic.path))
add("implementation", project(LibraryModule.AuthenticationLogic.path))
add("implementation", project(LibraryModule.CoreLogic.path))
add("implementation", project(LibraryModule.StorageLogic.path))
add("testImplementation", project(LibraryModule.TestFeatureLogic.path))
add("androidTestImplementation", project(LibraryModule.TestFeatureLogic.path))
}
Expand Down
35 changes: 35 additions & 0 deletions build-logic/convention/src/main/kotlin/RealmPlugin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2023 European Commission
*
* Licensed under the EUPL, Version 1.2 or - as soon they will be approved by the European
* Commission - subsequent versions of the EUPL (the "Licence"); You may not use this work
* except in compliance with the Licence.
*
* You may obtain a copy of the Licence at:
* https://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the Licence for the specific language
* governing permissions and limitations under the Licence.
*/

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
import project.convention.logic.libs

class RealmPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("io.realm.kotlin")
}

dependencies {
add("implementation", libs.findLibrary("kotlinx-coroutines").get())
add("implementation", libs.findLibrary("kotlin-realm").get())
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ internal fun Project.configureKotlinAndroid(
packaging {
resources {
excludes.add("/META-INF/{AL2.0,LGPL2.1}")
excludes.add("/META-INF/versions/9/OSGI-INF/MANIFEST.MF")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ enum class LibraryModule(val path: String) {
UiLogic(":ui-logic"),
NetworkLogic(":network-logic"),
ResourcesLogic(":resources-logic"),
StorageLogic(":storage-logic"),
BaselineProfileLogic(":baseline-profile"),
CommonFeature(":common-feature"),
StartupFeature(":startup-feature"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ package project.convention.logic.kover

import project.convention.logic.config.LibraryModule

private const val KOIN = "org.koin.*"
private const val BUILD_CONFIG = "eu.europa.ec.*.BuildConfig"
private const val SCREEN_COMPOSABLES = "eu.europa.ec.*.ui.*.*Screen*"
private const val KOIN = "*.ksp.*"
private const val BUILD_CONFIG = "*BuildConfig*"
private const val SCREEN_COMPOSABLES = "*Screen*"
private const val MODELS = "eu.europa.ec.*.model"
private const val DI = "eu.europa.ec.*.di"
private const val ROUTER_GRAPH = "eu.europa.ec.*.router"
Expand All @@ -40,13 +40,13 @@ val koverModules: Map<LibraryModule, KoverExclusionRules> = mapOf(
sealed interface KoverExclusionRules {
val commonClasses: List<String>
get() = listOf(
KOIN,
BUILD_CONFIG,
SCREEN_COMPOSABLES,
)

val commonPackages: List<String>
get() = listOf(
KOIN,
DI,
MODELS,
ROUTER_GRAPH,
Expand Down Expand Up @@ -216,4 +216,14 @@ sealed interface KoverExclusionRules {
"eu.europa.ec.corelogic"
)
}

object StorageLogic : LogicModule {
override val classes: List<String>
get() = commonClasses

override val packages: List<String>
get() = commonPackages + listOf(
"eu.europa.ec.storagelogic"
)
}
}
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ plugins {
alias(libs.plugins.android.test) apply false
alias(libs.plugins.baselineprofile) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.realm) apply false
}
true
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package eu.europa.ec.businesslogic.controller.storage
import android.content.SharedPreferences
import androidx.security.crypto.EncryptedSharedPreferences
import androidx.security.crypto.MasterKey
import eu.europa.ec.businesslogic.extension.decodeFromPemBase64String
import eu.europa.ec.resourceslogic.provider.ResourceProvider

interface PrefsController {
Expand Down Expand Up @@ -310,6 +311,8 @@ class PrefsControllerImpl(
interface PrefKeys {
fun getBiometricAlias(): String
fun setBiometricAlias(value: String)
fun getStorageKey(): ByteArray?
fun setStorageKey(key: String)
}

class PrefKeysImpl(
Expand All @@ -331,4 +334,13 @@ class PrefKeysImpl(
override fun setBiometricAlias(value: String) {
prefsController.setString("BiometricAlias", value)
}

override fun setStorageKey(key: String) {
prefsController.setString("StorageKey", key)
}

override fun getStorageKey(): ByteArray? {
val key = prefsController.getString("StorageKey", "")
return if (key.isNotEmpty()) key.decodeFromPemBase64String() else null
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2023 European Commission
*
* Licensed under the EUPL, Version 1.2 or - as soon they will be approved by the European
* Commission - subsequent versions of the EUPL (the "Licence"); You may not use this work
* except in compliance with the Licence.
*
* You may obtain a copy of the Licence at:
* https://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the Licence for the specific language
* governing permissions and limitations under the Licence.
*/

package eu.europa.ec.businesslogic.extension

fun <T> MutableList<T>.addOrReplace(value: T, replaceCondition: (T) -> Boolean) {
for (i in indices) {
if (replaceCondition(this[i])) {
this[i] = value
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import eu.europa.ec.commonfeature.ui.document_details.model.DocumentDetailsUi
import eu.europa.ec.corelogic.model.DocumentIdentifier
import eu.europa.ec.corelogic.model.isSupported
import eu.europa.ec.corelogic.model.toDocumentIdentifier
import eu.europa.ec.eudi.iso18013.transfer.RequestDocument
import eu.europa.ec.eudi.iso18013.transfer.response.RequestedDocument
import eu.europa.ec.eudi.wallet.document.Document
import eu.europa.ec.eudi.wallet.document.DocumentId
import eu.europa.ec.resourceslogic.R
Expand Down Expand Up @@ -61,10 +61,10 @@ fun Document.toUiName(resourceProvider: ResourceProvider): String {
)
}

fun RequestDocument.toUiName(resourceProvider: ResourceProvider): String {
fun RequestedDocument.toUiName(resourceProvider: ResourceProvider): String {
val docIdentifier = this.toDocumentIdentifier()
return docIdentifier.toUiName(
fallbackDocName = this.docName,
fallbackDocName = this.documentId,
resourceProvider = resourceProvider
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ package eu.europa.ec.commonfeature.ui.request.model

import eu.europa.ec.commonfeature.util.keyIsBase64
import eu.europa.ec.corelogic.model.DocType
import eu.europa.ec.eudi.iso18013.transfer.DocItem
import eu.europa.ec.eudi.iso18013.transfer.DocRequest
import eu.europa.ec.eudi.iso18013.transfer.response.DocItem
import eu.europa.ec.eudi.wallet.document.Document
import eu.europa.ec.eudi.wallet.document.DocumentId
import eu.europa.ec.eudi.wallet.document.ElementIdentifier
import eu.europa.ec.eudi.wallet.document.format.MsoMdocFormat

data class RequestDocumentItemUi<T>(
val id: String,
Expand All @@ -42,7 +43,6 @@ data class RequestDocumentItemUi<T>(
data class DocumentItemDomainPayload(
val docId: String,
val docType: DocType,
val docRequest: DocRequest,
val namespace: String,
val elementIdentifier: ElementIdentifier
) {
Expand Down Expand Up @@ -81,5 +81,12 @@ fun <T> DocItem.toRequestDocumentItemUi(
)
}

fun DocRequest.produceDocUID(elementIdentifier: ElementIdentifier, documentId: DocumentId): String =
val Document.docType: String
get() = (this.format as? MsoMdocFormat)?.docType.orEmpty()

fun produceDocUID(
elementIdentifier: ElementIdentifier,
documentId: DocumentId,
docType: String
): String =
docType + elementIdentifier + documentId
Loading
Loading