-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from a-sit-plus/feature/refactorRequestParser
Extend RequestParsing to SignatureRequests
- Loading branch information
Showing
19 changed files
with
420 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...rs/SignatureRequestParameterSerializer.kt → ...CSCSignatureRequestParameterSerializer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
openid-data-classes/src/commonMain/kotlin/at/asitplus/openid/JwsSignedSerializer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package at.asitplus.openid | ||
|
||
import at.asitplus.signum.indispensable.josef.JwsSigned | ||
import kotlinx.serialization.KSerializer | ||
import kotlinx.serialization.descriptors.PrimitiveKind | ||
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor | ||
import kotlinx.serialization.descriptors.SerialDescriptor | ||
import kotlinx.serialization.encoding.Decoder | ||
import kotlinx.serialization.encoding.Encoder | ||
|
||
object JwsSignedSerializer : KSerializer<JwsSigned> { | ||
|
||
override val descriptor: SerialDescriptor = | ||
PrimitiveSerialDescriptor("JwsSignedSerializer", PrimitiveKind.STRING) | ||
|
||
override fun deserialize(decoder: Decoder): JwsSigned = JwsSigned.deserialize(decoder.decodeString()).getOrThrow() | ||
|
||
override fun serialize(encoder: Encoder, value: JwsSigned) { | ||
encoder.encodeString(value.serialize()) | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
openid-data-classes/src/commonMain/kotlin/at/asitplus/openid/RequestParameters.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package at.asitplus.openid | ||
|
||
import kotlinx.serialization.DeserializationStrategy | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.json.JsonContentPolymorphicSerializer | ||
import kotlinx.serialization.json.JsonElement | ||
import kotlinx.serialization.json.jsonObject | ||
|
||
@Serializable | ||
sealed interface RequestParameters { | ||
val responseType: String? | ||
val clientId: String? | ||
val clientIdScheme: OpenIdConstants.ClientIdScheme? | ||
val responseMode: OpenIdConstants.ResponseMode? | ||
val responseUrl: String? | ||
val nonce: String? | ||
val state: String? | ||
} | ||
|
||
object RequestParametersSerializer : JsonContentPolymorphicSerializer<RequestParameters>(RequestParameters::class) { | ||
override fun selectDeserializer(element: JsonElement): DeserializationStrategy<RequestParameters> { | ||
val parameters = element.jsonObject | ||
return when { | ||
"signatureQualifier" in parameters -> SignatureRequestParameters.serializer() | ||
else -> AuthenticationRequestParameters.serializer() | ||
} | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.