diff --git a/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/issue/openid4vci/DefaultOpenId4VciManager.kt b/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/issue/openid4vci/DefaultOpenId4VciManager.kt index 0ffb0fb0..ee5b869e 100644 --- a/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/issue/openid4vci/DefaultOpenId4VciManager.kt +++ b/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/issue/openid4vci/DefaultOpenId4VciManager.kt @@ -21,6 +21,8 @@ import android.net.Uri import eu.europa.ec.eudi.openid4vci.DefaultHttpClientFactory import eu.europa.ec.eudi.openid4vci.DeferredIssuer import eu.europa.ec.eudi.wallet.document.* +import eu.europa.ec.eudi.wallet.issue.openidvci.PARResponse +import eu.europa.ec.eudi.wallet.issue.openidvci.PKCEVerifier import eu.europa.ec.eudi.wallet.internal.mainExecutor import eu.europa.ec.eudi.wallet.issue.openid4vci.IssueEvent.Companion.failure import eu.europa.ec.eudi.wallet.logging.Logger @@ -187,6 +189,17 @@ internal class DefaultOpenId4VciManager( resumeWithAuthorization(Uri.parse(uri)) } + override suspend fun performPushAuthorizationRequest(docType: String): PARResponse { + val offer = offerCreator.createOffer(docType) + val issuer = issuerCreator.createIssuer(offer) + val parResponse = issuerAuthorization.performPushAuthorizationRequest(issuer) + return PARResponse( + authorizationCodeURL = parResponse.authorizationCodeURL.value, + pkceVerifier = PKCEVerifier(codeVerifier = parResponse.pkceVerifier.codeVerifier, codeVerifierMethod = parResponse.pkceVerifier.codeVerifierMethod), + state = parResponse.state + ) + } + /** * Issues the given [Offer]. */ @@ -195,7 +208,6 @@ internal class DefaultOpenId4VciManager( txCode: String?, listener: OpenId4VciManager.OnResult, ) { - offer as DefaultOffer val issuer = issuerCreator.createIssuer(offer) var authorizedRequest = issuerAuthorization.authorize(issuer, txCode) listener(IssueEvent.Started(offer.offeredDocuments.size)) diff --git a/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/issue/openid4vci/IssuerAuthorization.kt b/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/issue/openid4vci/IssuerAuthorization.kt index 9aef4225..51ef3a30 100644 --- a/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/issue/openid4vci/IssuerAuthorization.kt +++ b/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/issue/openid4vci/IssuerAuthorization.kt @@ -44,6 +44,10 @@ internal class IssuerAuthorization( var continuation: CancellableContinuation>? = null + suspend fun performPushAuthorizationRequest(issuer: Issuer): AuthorizationRequestPrepared { + return issuer.prepareAuthorizationRequest().getOrThrow() + } + /** * Authorizes the given [Issuer] and returns the authorized request. * If txCode is provided, it will be used to authorize the issuer, diff --git a/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/issue/openid4vci/OpenId4VciManager.kt b/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/issue/openid4vci/OpenId4VciManager.kt index 60f66928..67f539b7 100644 --- a/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/issue/openid4vci/OpenId4VciManager.kt +++ b/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/issue/openid4vci/OpenId4VciManager.kt @@ -19,11 +19,13 @@ package eu.europa.ec.eudi.wallet.issue.openid4vci import android.content.Context import android.net.Uri import androidx.annotation.IntDef +import eu.europa.ec.eudi.openid4vci.AuthorizationRequestPrepared import eu.europa.ec.eudi.wallet.document.DeferredDocument import eu.europa.ec.eudi.wallet.document.DocumentManager import eu.europa.ec.eudi.wallet.issue.openid4vci.OpenId4VciManager.Config.ParUsage.Companion.IF_SUPPORTED import eu.europa.ec.eudi.wallet.issue.openid4vci.OpenId4VciManager.Config.ParUsage.Companion.NEVER import eu.europa.ec.eudi.wallet.issue.openid4vci.OpenId4VciManager.Config.ParUsage.Companion.REQUIRED +import eu.europa.ec.eudi.wallet.issue.openidvci.PARResponse import eu.europa.ec.eudi.wallet.logging.Logger import io.ktor.client.* import java.util.concurrent.Executor @@ -377,4 +379,6 @@ interface OpenId4VciManager { fun make(block: Builder.() -> Unit) = Builder().apply(block).build() } } + + suspend fun performPushAuthorizationRequest(docType: String): PARResponse } \ No newline at end of file diff --git a/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/issue/openidvci/PARResponse.kt b/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/issue/openidvci/PARResponse.kt new file mode 100644 index 00000000..460883e1 --- /dev/null +++ b/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/issue/openidvci/PARResponse.kt @@ -0,0 +1,14 @@ +package eu.europa.ec.eudi.wallet.issue.openidvci + +import java.net.URL + +data class PARResponse ( + val authorizationCodeURL: URL, + val pkceVerifier: PKCEVerifier, + val state: String, +) + +data class PKCEVerifier( + val codeVerifier: String, + val codeVerifierMethod: String, +) \ No newline at end of file