Skip to content

Commit

Permalink
Merge pull request #225 from niscy-eudiw/main
Browse files Browse the repository at this point in the history
RQES Implementation & Integration with the RQES UI SDK
  • Loading branch information
stzouvaras authored Nov 20, 2024
2 parents 9bced89 + 4e64081 commit e5fffac
Show file tree
Hide file tree
Showing 27 changed files with 512 additions and 8 deletions.
1 change: 1 addition & 0 deletions assembly-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import project.convention.logic.kover.koverModules
plugins {
id("project.android.library")
id("project.android.library.compose")
id("project.rqes.sdk")
}

android {
Expand Down
12 changes: 12 additions & 0 deletions assembly-logic/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,18 @@
android:scheme="${openId4VciAuthorizationScheme}" />

</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="${rqesHost}"
android:path="${rqesPath}"
android:scheme="${rqesScheme}" />

</intent-filter>
</activity>

</application>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,38 @@ package eu.europa.ec.assemblylogic
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()
setupKoin()
initializeKoin().initializeRqes()
initializeReporting()
initializeEudiWallet()
}

private fun KoinApplication.initializeRqes() {
EudiRQESUi.setup(
application = this@Application,
config = configLogic.rqesConfig,
koinApplication = this@initializeRqes
)
}

private fun initializeKoin(): KoinApplication {
return setupKoin()
}

private fun initializeReporting() {
analyticsController.initialize(this)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import eu.europa.ec.startupfeature.di.FeatureStartupModule
import eu.europa.ec.uilogic.di.LogicUiModule
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
import org.koin.core.KoinApplication
import org.koin.core.context.GlobalContext.startKoin
import org.koin.ksp.generated.module

Expand All @@ -57,8 +58,8 @@ private val assembledModules = listOf(
FeatureIssuanceModule().module
)

internal fun Application.setupKoin() {
startKoin {
internal fun Application.setupKoin(): KoinApplication {
return startKoin {
androidContext(this@setupKoin)
androidLogger()
modules(assembledModules)
Expand Down
4 changes: 4 additions & 0 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,9 @@ gradlePlugin {
id = "project.android.base.profile"
implementationClass = "AndroidBaseLineProfilePlugin"
}
register("eudiRqes") {
id = "project.rqes.sdk"
implementationClass = "EudiRqesPlugin"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
val openId4VciAuthorizationScheme = "eu.europa.ec.euidi"
val openId4VciAuthorizationHost = "authorization"

val rqesScheme = "rqes"
val rqesHost = "oauth"
val rqesPath = "/callback"

with(pluginManager) {
apply("com.android.library")
apply("project.android.library.kover")
Expand Down Expand Up @@ -87,6 +91,9 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
"ISSUE_AUTHORIZATION_DEEPLINK",
"$openId4VciAuthorizationScheme://$openId4VciAuthorizationHost"
)
addConfigField("RQES_SCHEME", rqesScheme)
addConfigField("RQES_HOST", rqesHost)
addConfigField("RQES_DEEPLINK", "$rqesScheme://$rqesHost$rqesPath")

// Manifest placeholders for Wallet deepLink
manifestPlaceholders["deepLinkScheme"] = walletScheme
Expand All @@ -109,6 +116,11 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
openId4VciAuthorizationScheme
manifestPlaceholders["openId4VciAuthorizationHost"] =
openId4VciAuthorizationHost

// Manifest placeholders used for RQES
manifestPlaceholders["rqesHost"] = rqesHost
manifestPlaceholders["rqesScheme"] = rqesScheme
manifestPlaceholders["rqesPath"] = rqesPath
}
configureFlavors(this)
configureGradleManagedDevices(this)
Expand Down
30 changes: 30 additions & 0 deletions build-logic/convention/src/main/kotlin/EudiRqesPlugin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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 EudiRqesPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
dependencies {
add("implementation", libs.findLibrary("rqes-ui-sdk").get())
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal fun Project.configureKotlinAndroid(
compileSdk = 35

defaultConfig {
minSdk = 26
minSdk = 28
}

buildFeatures {
Expand Down
1 change: 1 addition & 0 deletions business-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import project.convention.logic.kover.excludeFromKoverReport

plugins {
id("project.android.library")
id("project.rqes.sdk")
}

android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,50 @@

package eu.europa.ec.businesslogic.config

import eu.europa.ec.businesslogic.BuildConfig
import eu.europa.ec.eudi.rqes.HashAlgorithmOID
import eu.europa.ec.eudi.rqes.SigningAlgorithmOID
import eu.europa.ec.eudi.rqesui.domain.extension.toUri
import eu.europa.ec.eudi.rqesui.infrastructure.config.EudiRQESUiConfig
import eu.europa.ec.eudi.rqesui.infrastructure.config.RqesServiceConfig
import eu.europa.ec.eudi.rqesui.infrastructure.config.data.QtspData
import java.net.URI

class ConfigLogicImpl : ConfigLogic {
override val appFlavor: AppFlavor
get() = AppFlavor.DEMO

override val environmentConfig: EnvironmentConfig
get() = DemoEnvironmentConfig()

override val rqesConfig: EudiRQESUiConfig
get() = RqesConfig()
}

private class DemoEnvironmentConfig : EnvironmentConfig() {
override fun getServerHost(): String = when (environment) {
ServerConfig.Debug -> ""
ServerConfig.Release -> ""
}
}

private class RqesConfig : EudiRQESUiConfig {

override val rqesServiceConfig: RqesServiceConfig
get() = RqesServiceConfig(
clientId = "wallet-client",
clientSecret = "somesecret2",
authFlowRedirectionURI = URI.create(BuildConfig.RQES_DEEPLINK),
signingAlgorithm = SigningAlgorithmOID.RSA,
hashAlgorithm = HashAlgorithmOID.SHA_256,
)

override val qtsps: List<QtspData>
get() = listOf(
QtspData(
name = "Wallet-Centric",
endpoint = "https://walletcentric.signer.eudiw.dev/csc/v2".toUri(),
scaUrl = "https://walletcentric.signer.eudiw.dev",
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,50 @@

package eu.europa.ec.businesslogic.config

import eu.europa.ec.businesslogic.BuildConfig
import eu.europa.ec.eudi.rqes.HashAlgorithmOID
import eu.europa.ec.eudi.rqes.SigningAlgorithmOID
import eu.europa.ec.eudi.rqesui.domain.extension.toUri
import eu.europa.ec.eudi.rqesui.infrastructure.config.EudiRQESUiConfig
import eu.europa.ec.eudi.rqesui.infrastructure.config.RqesServiceConfig
import eu.europa.ec.eudi.rqesui.infrastructure.config.data.QtspData
import java.net.URI

class ConfigLogicImpl : ConfigLogic {
override val appFlavor: AppFlavor
get() = AppFlavor.DEV

override val environmentConfig: EnvironmentConfig
get() = DevEnvironmentConfig()

override val rqesConfig: EudiRQESUiConfig
get() = RqesConfig()
}

private class DevEnvironmentConfig : EnvironmentConfig() {
override fun getServerHost(): String = when (environment) {
ServerConfig.Debug -> ""
ServerConfig.Release -> ""
}
}

private class RqesConfig : EudiRQESUiConfig {

override val rqesServiceConfig: RqesServiceConfig
get() = RqesServiceConfig(
clientId = "wallet-client",
clientSecret = "somesecret2",
authFlowRedirectionURI = URI.create(BuildConfig.RQES_DEEPLINK),
signingAlgorithm = SigningAlgorithmOID.RSA,
hashAlgorithm = HashAlgorithmOID.SHA_256,
)

override val qtsps: List<QtspData>
get() = listOf(
QtspData(
name = "Wallet-Centric",
endpoint = "https://walletcentric.signer.eudiw.dev/csc/v2".toUri(),
scaUrl = "https://walletcentric.signer.eudiw.dev",
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package eu.europa.ec.businesslogic.config

import eu.europa.ec.businesslogic.BuildConfig
import eu.europa.ec.eudi.rqesui.infrastructure.config.EudiRQESUiConfig

interface ConfigLogic {

Expand All @@ -39,6 +40,11 @@ interface ConfigLogic {
* Application version.
*/
val appVersion: String get() = BuildConfig.APP_VERSION

/**
* RQES Config.
*/
val rqesConfig: EudiRQESUiConfig
}

enum class AppFlavor {
Expand Down
1 change: 1 addition & 0 deletions dashboard-feature/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import project.convention.logic.kover.excludeFromKoverReport

plugins {
id("project.android.feature")
id("project.rqes.sdk")
}

android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import eu.europa.ec.corelogic.config.WalletCoreConfig
import eu.europa.ec.corelogic.controller.WalletCoreDocumentsController
import eu.europa.ec.dashboardfeature.interactor.DashboardInteractor
import eu.europa.ec.dashboardfeature.interactor.DashboardInteractorImpl
import eu.europa.ec.dashboardfeature.interactor.DocumentSignInteractor
import eu.europa.ec.dashboardfeature.interactor.DocumentSignInteractorImpl
import eu.europa.ec.resourceslogic.provider.ResourceProvider
import org.koin.core.annotation.ComponentScan
import org.koin.core.annotation.Factory
Expand All @@ -37,12 +39,16 @@ fun provideDashboardInteractor(
walletCoreDocumentsController: WalletCoreDocumentsController,
walletCoreConfig: WalletCoreConfig,
configLogic: ConfigLogic,
logController: LogController
logController: LogController,
): DashboardInteractor =
DashboardInteractorImpl(
resourceProvider,
walletCoreDocumentsController,
walletCoreConfig,
configLogic,
logController
)
)

@Factory
fun provideDocumentSignInteractor(): DocumentSignInteractor =
DocumentSignInteractorImpl()
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.dashboardfeature.interactor

import android.content.Context
import android.net.Uri
import eu.europa.ec.eudi.rqesui.infrastructure.EudiRQESUi

interface DocumentSignInteractor {
fun launchRQESSdk(context: Context, uri: Uri)
}

class DocumentSignInteractorImpl : DocumentSignInteractor {
override fun launchRQESSdk(context: Context, uri: Uri) {
EudiRQESUi.initiate(context, uri)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import androidx.navigation.compose.navigation
import androidx.navigation.navDeepLink
import eu.europa.ec.dashboardfeature.BuildConfig
import eu.europa.ec.dashboardfeature.ui.dashboard.DashboardScreen
import eu.europa.ec.dashboardfeature.ui.sign.DocumentSignScreen
import eu.europa.ec.uilogic.navigation.DashboardScreens
import eu.europa.ec.uilogic.navigation.ModuleRoute
import org.koin.androidx.compose.koinViewModel
Expand All @@ -43,5 +44,11 @@ fun NavGraphBuilder.featureDashboardGraph(navController: NavController) {
) {
DashboardScreen(navController, koinViewModel())
}

composable(
route = DashboardScreens.SignDocument.screenRoute
) {
DocumentSignScreen(navController, koinViewModel())
}
}
}
Loading

0 comments on commit e5fffac

Please sign in to comment.