diff --git a/modules/openid-federation-common/src/commonMain/kotlin/com/sphereon/oid/fed/common/httpclient/OidFederationClient.kt b/modules/openid-federation-common/src/commonMain/kotlin/com/sphereon/oid/fed/common/httpclient/OidFederationClient.kt index f2e261e9..9b5752b9 100644 --- a/modules/openid-federation-common/src/commonMain/kotlin/com/sphereon/oid/fed/common/httpclient/OidFederationClient.kt +++ b/modules/openid-federation-common/src/commonMain/kotlin/com/sphereon/oid/fed/common/httpclient/OidFederationClient.kt @@ -1,6 +1,5 @@ package com.sphereon.oid.fed.common.httpclient -import com.sphereon.oid.fed.common.jwt.KMSInterface import com.sphereon.oid.fed.openapi.models.JWTHeader import io.ktor.client.* import io.ktor.client.call.* diff --git a/modules/openid-federation-common/src/commonMain/kotlin/com/sphereon/oid/fed/common/jwt/KMSInterface.kt b/modules/openid-federation-common/src/commonMain/kotlin/com/sphereon/oid/fed/common/jwt/KMSInterface.kt index b78f9ca1..62bfd7a6 100644 --- a/modules/openid-federation-common/src/commonMain/kotlin/com/sphereon/oid/fed/common/jwt/KMSInterface.kt +++ b/modules/openid-federation-common/src/commonMain/kotlin/com/sphereon/oid/fed/common/jwt/KMSInterface.kt @@ -1,6 +1,5 @@ package com.sphereon.oid.fed.common.jwt -import com.sphereon.oid.fed.common.mapper.JsonMapper import com.sphereon.oid.fed.openapi.models.JWTHeader import kotlinx.serialization.json.JsonObject diff --git a/modules/openid-federation-common/src/jsMain/kotlin/com/sphereon/oid/fed/common/jwt/JoseJwt.js.kt b/modules/openid-federation-common/src/jsMain/kotlin/com/sphereon/oid/fed/common/jwt/JoseJwt.js.kt index 5dbbcc10..1dfcf9c1 100644 --- a/modules/openid-federation-common/src/jsMain/kotlin/com/sphereon/oid/fed/common/jwt/JoseJwt.js.kt +++ b/modules/openid-federation-common/src/jsMain/kotlin/com/sphereon/oid/fed/common/jwt/JoseJwt.js.kt @@ -1,6 +1,5 @@ package com.sphereon.oid.fed.common.jwt -import com.sphereon.oid.fed.openapi.models.EntityConfigurationStatement import com.sphereon.oid.fed.openapi.models.JWTHeader import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json diff --git a/modules/openid-federation-common/src/jsTest/kotlin/com/sphereon/oid/fed/common/jwt/JoseJwtTest.js.kt b/modules/openid-federation-common/src/jsTest/kotlin/com/sphereon/oid/fed/common/jwt/JoseJwtTest.js.kt index 67ba6a18..17173acd 100644 --- a/modules/openid-federation-common/src/jsTest/kotlin/com/sphereon/oid/fed/common/jwt/JoseJwtTest.js.kt +++ b/modules/openid-federation-common/src/jsTest/kotlin/com/sphereon/oid/fed/common/jwt/JoseJwtTest.js.kt @@ -2,8 +2,8 @@ package com.sphereon.oid.fed.common.jwt import com.sphereon.oid.fed.common.jwt.Jose.generateKeyPair import com.sphereon.oid.fed.openapi.models.EntityStatement -import com.sphereon.oid.fed.openapi.models.JWTHeader import com.sphereon.oid.fed.openapi.models.JWKS +import com.sphereon.oid.fed.openapi.models.JWTHeader import kotlinx.coroutines.async import kotlinx.coroutines.await import kotlinx.coroutines.test.runTest diff --git a/modules/openid-federation-common/src/jvmMain/kotlin/com/sphereon/oid/fed/common/jwt/JoseJwt.jvm.kt b/modules/openid-federation-common/src/jvmMain/kotlin/com/sphereon/oid/fed/common/jwt/JoseJwt.jvm.kt index 567400f7..06bfef16 100644 --- a/modules/openid-federation-common/src/jvmMain/kotlin/com/sphereon/oid/fed/common/jwt/JoseJwt.jvm.kt +++ b/modules/openid-federation-common/src/jvmMain/kotlin/com/sphereon/oid/fed/common/jwt/JoseJwt.jvm.kt @@ -1,9 +1,6 @@ package com.sphereon.oid.fed.common.jwt import com.nimbusds.jose.* -import com.nimbusds.jose.JWSHeader -import com.nimbusds.jose.JWSSigner -import com.nimbusds.jose.JWSVerifier import com.nimbusds.jose.crypto.RSASSASigner import com.nimbusds.jose.crypto.RSASSAVerifier import com.nimbusds.jose.jwk.RSAKey diff --git a/modules/openid-federation-common/src/jvmTest/kotlin/com/sphereon/oid/fed/common/httpclient/OidFederationClientTest.kt b/modules/openid-federation-common/src/jvmTest/kotlin/com/sphereon/oid/fed/common/httpclient/OidFederationClientTest.kt index 21379bf5..a0bbf510 100644 --- a/modules/openid-federation-common/src/jvmTest/kotlin/com/sphereon/oid/fed/common/httpclient/OidFederationClientTest.kt +++ b/modules/openid-federation-common/src/jvmTest/kotlin/com/sphereon/oid/fed/common/httpclient/OidFederationClientTest.kt @@ -1,11 +1,11 @@ package com.sphereon.oid.fed.common.httpclient import com.nimbusds.jose.jwk.gen.RSAKeyGenerator -import com.sphereon.oid.fed.openapi.models.* +import com.sphereon.oid.fed.openapi.models.EntityStatement +import com.sphereon.oid.fed.openapi.models.JWTHeader import io.ktor.client.engine.mock.* import io.ktor.http.* import kotlinx.coroutines.runBlocking -import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.encodeToJsonElement @@ -41,7 +41,10 @@ class OidFederationClientTest { fun testGetEntityStatement() { runBlocking { val client = OidFederationClient(mockEngine) - val response = client.fetchEntityStatement("https://www.example.com?iss=https://edugain.org/federation&sub=https://openid.sunet.se", HttpMethod.Get) + val response = client.fetchEntityStatement( + "https://www.example.com?iss=https://edugain.org/federation&sub=https://openid.sunet.se", + HttpMethod.Get + ) assertEquals(jwt, response) } } @@ -51,9 +54,11 @@ class OidFederationClientTest { runBlocking { val client = OidFederationClient(mockEngine) val key = RSAKeyGenerator(2048).keyID("key1").generate() - val entityStatement = EntityStatement(iss = "https://edugain.org/federation", sub = "https://openid.sunet.se") + val entityStatement = + EntityStatement(iss = "https://edugain.org/federation", sub = "https://openid.sunet.se") val payload: JsonObject = Json.encodeToJsonElement(entityStatement) as JsonObject - val response = client.fetchEntityStatement("https://www.example.com", HttpMethod.Post, + val response = client.fetchEntityStatement( + "https://www.example.com", HttpMethod.Post, OidFederationClient.PostEntityParameters( payload = payload, header = JWTHeader(typ = "JWT", alg = "RS256", kid = key.keyID) diff --git a/modules/openid-federation-common/src/jvmTest/kotlin/com/sphereon/oid/fed/common/jwt/JoseJwtTest.jvm.kt b/modules/openid-federation-common/src/jvmTest/kotlin/com/sphereon/oid/fed/common/jwt/JoseJwtTest.jvm.kt index 099aaa8c..0302071f 100644 --- a/modules/openid-federation-common/src/jvmTest/kotlin/com/sphereon/oid/fed/common/jwt/JoseJwtTest.jvm.kt +++ b/modules/openid-federation-common/src/jvmTest/kotlin/com/sphereon/oid/fed/common/jwt/JoseJwtTest.jvm.kt @@ -18,9 +18,7 @@ class JoseJwtTest { val entityStatement = EntityStatement(iss = "test") val payload: JsonObject = Json.encodeToJsonElement(entityStatement) as JsonObject val signature = sign( - payload, - JWTHeader(alg = "RS256", typ = "JWT", kid = key.keyID), - mutableMapOf("key" to key) + payload, JWTHeader(alg = "RS256", typ = "JWT", kid = key.keyID), mutableMapOf("key" to key) ) assertTrue { signature.startsWith("ey") } } @@ -32,9 +30,7 @@ class JoseJwtTest { val entityStatement = EntityStatement(iss = "test") val payload: JsonObject = Json.encodeToJsonElement(entityStatement) as JsonObject val signature = sign( - payload, - JWTHeader(alg = "RS256", typ = "JWT", kid = key.keyID), - mutableMapOf("key" to key) + payload, JWTHeader(alg = "RS256", typ = "JWT", kid = key.keyID), mutableMapOf("key" to key) ) assertTrue { verify(signature, key, emptyMap()) } }