From b3c1b00a2d9d03db906ae47658f7a81d3434bb5b Mon Sep 17 00:00:00 2001 From: Christian Kollmann Date: Mon, 21 Oct 2024 08:27:21 +0200 Subject: [PATCH] Rename objects and classes to match expected casing --- CHANGELOG.md | 1 + .../at/asitplus/openid/OpenIdConstants.kt | 24 +++++++++---------- .../wallet/lib/oidc/OidcSiopVerifier.kt | 12 +++++----- .../helper/AuthenticationResponseFactory.kt | 10 ++++---- .../helper/AuthorizationRequestValidator.kt | 6 ++--- .../wallet/lib/oidc/OidcSiopInteropTest.kt | 7 ++---- .../lib/oidc/OidcSiopIsoProtocolTest.kt | 2 +- .../wallet/lib/oidc/OidcSiopProtocolTest.kt | 6 ++--- .../wallet/lib/oidc/OidcSiopX509SanDnsTest.kt | 2 +- .../wallet/lib/oidvci/SerializationTest.kt | 2 +- 10 files changed, 35 insertions(+), 37 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f99953d..cf5a786e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Release 5.1.0: - Replace `buildIssuerCredentialDataProviderOverride` in `CredentialIssuer` with `credentialProvider` to extract user information into a credential - Remove `dataProvider` from `IssuerAgent`s constructor, as it is not needed with the new issuing interface anyway - Replace `relyingPartyUrl` with `clientIdScheme` on `OidcSiopVerifier`s constructor, to clarify use of `client_id` in requests + - Rename objects in `OpenIdConstants.ProofType`, `OpenIdConstants.CliendIdScheme` and `OpenIdConstants.ResponseMode` Release 5.0.1: - Update JsonPath4K to 2.4.0 diff --git a/openid-data-classes/src/commonMain/kotlin/at/asitplus/openid/OpenIdConstants.kt b/openid-data-classes/src/commonMain/kotlin/at/asitplus/openid/OpenIdConstants.kt index 90a5525b..5b515541 100644 --- a/openid-data-classes/src/commonMain/kotlin/at/asitplus/openid/OpenIdConstants.kt +++ b/openid-data-classes/src/commonMain/kotlin/at/asitplus/openid/OpenIdConstants.kt @@ -78,7 +78,7 @@ object OpenIdConstants { * Any proof type not natively supported by this library */ @Serializable(with = Serializer::class) - class OTHER(stringRepresentation: String) : ProofType(stringRepresentation) + class Other(stringRepresentation: String) : ProofType(stringRepresentation) object Serializer : KSerializer { override val descriptor: SerialDescriptor = @@ -88,7 +88,7 @@ object OpenIdConstants { return when (val str = decoder.decodeString()) { STRING_JWT -> JWT STRING_CWT -> CWT - else -> OTHER(str) + else -> Other(str) } } @@ -263,7 +263,7 @@ object OpenIdConstants { * with a redirect URI to the Wallet. */ @Serializable(with = Serializer::class) - object DIRECT_POST : ResponseMode(STRING_DIRECT_POST) + object DirectPost : ResponseMode(STRING_DIRECT_POST) /** * OID4VP: The Response Mode `direct_post.jwt` causes the Wallet to send the Authorization Response using an @@ -272,37 +272,37 @@ object OpenIdConstants { * using the `application/x-www-form-urlencoded` content type. */ @Serializable(with = Serializer::class) - object DIRECT_POST_JWT : ResponseMode(STRING_DIRECT_POST_JWT) + object DirectPostJwt : ResponseMode(STRING_DIRECT_POST_JWT) /** * OAuth 2.0: In this mode, Authorization Response parameters are encoded in the query string added to the * `redirect_uri` when redirecting back to the Client. */ @Serializable(with = Serializer::class) - object QUERY : ResponseMode(STRING_QUERY) + object Query : ResponseMode(STRING_QUERY) /** * OAuth 2.0: In this mode, Authorization Response parameters are encoded in the fragment added to the * `redirect_uri` when redirecting back to the Client. */ @Serializable(with = Serializer::class) - object FRAGMENT : ResponseMode(STRING_FRAGMENT) + object Fragment : ResponseMode(STRING_FRAGMENT) /** * Any not natively supported Client ID Scheme, so it can still be parsed */ @Serializable(with = Serializer::class) - class OTHER(stringRepresentation: String) : ResponseMode(stringRepresentation) + class Other(stringRepresentation: String) : ResponseMode(stringRepresentation) object Serializer : KSerializer { override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("ResponseMode", PrimitiveKind.STRING) override fun deserialize(decoder: Decoder): ResponseMode { return when (val string = decoder.decodeString()) { - STRING_DIRECT_POST -> DIRECT_POST - STRING_DIRECT_POST_JWT -> DIRECT_POST_JWT - STRING_QUERY -> QUERY - STRING_FRAGMENT -> FRAGMENT - else -> OTHER(string) + STRING_DIRECT_POST -> DirectPost + STRING_DIRECT_POST_JWT -> DirectPostJwt + STRING_QUERY -> Query + STRING_FRAGMENT -> Fragment + else -> Other(string) } } diff --git a/vck-openid/src/commonMain/kotlin/at/asitplus/wallet/lib/oidc/OidcSiopVerifier.kt b/vck-openid/src/commonMain/kotlin/at/asitplus/wallet/lib/oidc/OidcSiopVerifier.kt index ca2c8d57..468b82db 100644 --- a/vck-openid/src/commonMain/kotlin/at/asitplus/wallet/lib/oidc/OidcSiopVerifier.kt +++ b/vck-openid/src/commonMain/kotlin/at/asitplus/wallet/lib/oidc/OidcSiopVerifier.kt @@ -217,14 +217,14 @@ class OidcSiopVerifier private constructor( val credentials: Set, /** * Response mode to request, see [OpenIdConstants.ResponseMode], - * by default [OpenIdConstants.ResponseMode.FRAGMENT]. + * by default [OpenIdConstants.ResponseMode.Fragment]. * Setting this to any other value may require setting [responseUrl] too. */ - val responseMode: OpenIdConstants.ResponseMode = OpenIdConstants.ResponseMode.FRAGMENT, + val responseMode: OpenIdConstants.ResponseMode = OpenIdConstants.ResponseMode.Fragment, /** * Response URL to set in the [AuthenticationRequestParameters.responseUrl], - * required if [responseMode] is set to [OpenIdConstants.ResponseMode.DIRECT_POST] or - * [OpenIdConstants.ResponseMode.DIRECT_POST_JWT]. + * required if [responseMode] is set to [OpenIdConstants.ResponseMode.DirectPost] or + * [OpenIdConstants.ResponseMode.DirectPostJwt]. */ val responseUrl: String? = null, /** @@ -394,8 +394,8 @@ class OidcSiopVerifier private constructor( ).joinToString(" ") private val RequestOptions.isAnyDirectPost - get() = (responseMode == OpenIdConstants.ResponseMode.DIRECT_POST) || - (responseMode == OpenIdConstants.ResponseMode.DIRECT_POST_JWT) + get() = (responseMode == OpenIdConstants.ResponseMode.DirectPost) || + (responseMode == OpenIdConstants.ResponseMode.DirectPostJwt) //TODO extend for InputDescriptor interface in case QES private fun RequestOptionsCredential.toInputDescriptor() = DifInputDescriptor( diff --git a/vck-openid/src/commonMain/kotlin/at/asitplus/wallet/lib/oidc/helper/AuthenticationResponseFactory.kt b/vck-openid/src/commonMain/kotlin/at/asitplus/wallet/lib/oidc/helper/AuthenticationResponseFactory.kt index ab4df1a6..4323fe53 100644 --- a/vck-openid/src/commonMain/kotlin/at/asitplus/wallet/lib/oidc/helper/AuthenticationResponseFactory.kt +++ b/vck-openid/src/commonMain/kotlin/at/asitplus/wallet/lib/oidc/helper/AuthenticationResponseFactory.kt @@ -26,11 +26,11 @@ internal class AuthenticationResponseFactory( request: AuthenticationRequestParametersFrom, response: AuthenticationResponse, ) = when (request.parameters.responseMode) { - DIRECT_POST -> authnResponseDirectPost(request, response) - DIRECT_POST_JWT -> authnResponseDirectPostJwt(request, response) - QUERY -> authnResponseQuery(request, response) - FRAGMENT, null -> authnResponseFragment(request, response) - is OTHER -> TODO() + DirectPost -> authnResponseDirectPost(request, response) + DirectPostJwt -> authnResponseDirectPostJwt(request, response) + Query -> authnResponseQuery(request, response) + Fragment, null -> authnResponseFragment(request, response) + is Other -> TODO() } /** diff --git a/vck-openid/src/commonMain/kotlin/at/asitplus/wallet/lib/oidc/helper/AuthorizationRequestValidator.kt b/vck-openid/src/commonMain/kotlin/at/asitplus/wallet/lib/oidc/helper/AuthorizationRequestValidator.kt index 4880bb83..4e312bb2 100644 --- a/vck-openid/src/commonMain/kotlin/at/asitplus/wallet/lib/oidc/helper/AuthorizationRequestValidator.kt +++ b/vck-openid/src/commonMain/kotlin/at/asitplus/wallet/lib/oidc/helper/AuthorizationRequestValidator.kt @@ -4,8 +4,8 @@ import at.asitplus.openid.AuthenticationRequestParameters import at.asitplus.openid.OpenIdConstants import at.asitplus.openid.OpenIdConstants.Errors import at.asitplus.openid.OpenIdConstants.ID_TOKEN -import at.asitplus.openid.OpenIdConstants.ResponseMode.DIRECT_POST -import at.asitplus.openid.OpenIdConstants.ResponseMode.DIRECT_POST_JWT +import at.asitplus.openid.OpenIdConstants.ResponseMode.DirectPost +import at.asitplus.openid.OpenIdConstants.ResponseMode.DirectPostJwt import at.asitplus.openid.OpenIdConstants.VP_TOKEN import at.asitplus.signum.indispensable.pki.leaf import at.asitplus.wallet.lib.oidc.AuthenticationRequestParametersFrom @@ -119,7 +119,7 @@ internal class AuthorizationRequestValidator { } private fun OpenIdConstants.ResponseMode?.isAnyDirectPost() = - (this == DIRECT_POST) || (this == DIRECT_POST_JWT) + (this == DirectPost) || (this == DirectPostJwt) @Throws(OAuth2Exception::class) private fun AuthenticationRequestParameters.verifyResponseModeDirectPost() { diff --git a/vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidc/OidcSiopInteropTest.kt b/vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidc/OidcSiopInteropTest.kt index 163427d1..bad1d5ae 100644 --- a/vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidc/OidcSiopInteropTest.kt +++ b/vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidc/OidcSiopInteropTest.kt @@ -19,7 +19,6 @@ import at.asitplus.wallet.lib.data.ConstantIndex.AtomicAttribute2023.CLAIM_FAMIL import at.asitplus.wallet.lib.data.ConstantIndex.AtomicAttribute2023.CLAIM_GIVEN_NAME import at.asitplus.wallet.lib.jws.DefaultJwsService import at.asitplus.wallet.lib.oidvci.decode -import at.asitplus.wallet.lib.oidvci.decodeFromUrlQuery import com.benasher44.uuid.uuid4 import io.kotest.core.spec.style.FreeSpec import io.kotest.matchers.collections.shouldBeSingleton @@ -27,8 +26,6 @@ import io.kotest.matchers.collections.shouldHaveSingleElement import io.kotest.matchers.nulls.shouldNotBeNull import io.kotest.matchers.shouldBe import io.kotest.matchers.types.shouldBeInstanceOf -import io.ktor.http.* -import io.ktor.util.* import kotlinx.datetime.Instant /** @@ -252,7 +249,7 @@ class OidcSiopInteropTest : FreeSpec({ parsed.responseType shouldBe "vp_token" parsed.nonce shouldBe "nonce" parsed.clientId shouldBe "verifier-backend.eudiw.dev" - parsed.responseMode shouldBe OpenIdConstants.ResponseMode.DIRECT_POST_JWT + parsed.responseMode shouldBe OpenIdConstants.ResponseMode.DirectPostJwt parsed.audience shouldBe "https://self-issued.me/v2" parsed.scope shouldBe "" val pd = parsed.presentationDefinition @@ -334,7 +331,7 @@ class OidcSiopInteropTest : FreeSpec({ walletUrl = "https://wallet.a-sit.at/mobile", requestUrl = requestUrl, requestOptions = OidcSiopVerifier.RequestOptions( - responseMode = OpenIdConstants.ResponseMode.DIRECT_POST, + responseMode = OpenIdConstants.ResponseMode.DirectPost, responseUrl = "https://example.com/response", credentials = setOf( OidcSiopVerifier.RequestOptionsCredential( diff --git a/vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidc/OidcSiopIsoProtocolTest.kt b/vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidc/OidcSiopIsoProtocolTest.kt index a8ab53fd..3eb0e28e 100644 --- a/vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidc/OidcSiopIsoProtocolTest.kt +++ b/vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidc/OidcSiopIsoProtocolTest.kt @@ -150,7 +150,7 @@ class OidcSiopIsoProtocolTest : FreeSpec({ MobileDrivingLicenceScheme, ConstantIndex.CredentialRepresentation.ISO_MDOC, listOf(requestedClaim) ) ), - responseMode = OpenIdConstants.ResponseMode.DIRECT_POST_JWT, + responseMode = OpenIdConstants.ResponseMode.DirectPostJwt, responseUrl = "https://example.com/response", encryption = true ) diff --git a/vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidc/OidcSiopProtocolTest.kt b/vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidc/OidcSiopProtocolTest.kt index 8e57533d..6f84f10d 100644 --- a/vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidc/OidcSiopProtocolTest.kt +++ b/vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidc/OidcSiopProtocolTest.kt @@ -162,7 +162,7 @@ class OidcSiopProtocolTest : FreeSpec({ walletUrl = walletUrl, requestOptions = RequestOptions( credentials = setOf(OidcSiopVerifier.RequestOptionsCredential(ConstantIndex.AtomicAttribute2023)), - responseMode = OpenIdConstants.ResponseMode.DIRECT_POST, + responseMode = OpenIdConstants.ResponseMode.DirectPost, responseUrl = clientId, ) ) @@ -182,7 +182,7 @@ class OidcSiopProtocolTest : FreeSpec({ walletUrl = walletUrl, requestOptions = RequestOptions( credentials = setOf(OidcSiopVerifier.RequestOptionsCredential(ConstantIndex.AtomicAttribute2023)), - responseMode = OpenIdConstants.ResponseMode.DIRECT_POST_JWT, + responseMode = OpenIdConstants.ResponseMode.DirectPostJwt, responseUrl = clientId, ) ) @@ -206,7 +206,7 @@ class OidcSiopProtocolTest : FreeSpec({ walletUrl = walletUrl, requestOptions = RequestOptions( credentials = setOf(OidcSiopVerifier.RequestOptionsCredential(ConstantIndex.AtomicAttribute2023)), - responseMode = OpenIdConstants.ResponseMode.QUERY, + responseMode = OpenIdConstants.ResponseMode.Query, state = expectedState ) ) diff --git a/vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidc/OidcSiopX509SanDnsTest.kt b/vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidc/OidcSiopX509SanDnsTest.kt index c23e27fd..00a3e486 100644 --- a/vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidc/OidcSiopX509SanDnsTest.kt +++ b/vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidc/OidcSiopX509SanDnsTest.kt @@ -76,7 +76,7 @@ class OidcSiopX509SanDnsTest : FreeSpec({ listOf(CLAIM_GIVEN_NAME) ) ), - responseMode = OpenIdConstants.ResponseMode.DIRECT_POST_JWT, + responseMode = OpenIdConstants.ResponseMode.DirectPostJwt, responseUrl = "https://example.com/response", ) ).getOrThrow() diff --git a/vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidvci/SerializationTest.kt b/vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidvci/SerializationTest.kt index 33292010..e9322008 100644 --- a/vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidvci/SerializationTest.kt +++ b/vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidvci/SerializationTest.kt @@ -61,7 +61,7 @@ class SerializationTest : FunSpec({ types = setOf(randomString(), randomString()), ), proof = CredentialRequestProof( - proofType = OpenIdConstants.ProofType.OTHER(randomString()), + proofType = OpenIdConstants.ProofType.Other(randomString()), jwt = randomString() ) )