Skip to content

Commit

Permalink
Add SignatureResponse classes
Browse files Browse the repository at this point in the history
  • Loading branch information
n0900 committed Nov 6, 2024
1 parent 888b6c9 commit f028a66
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ sealed class SignatureResponse {
val responseId: String?,
): SignatureResponse()

@Serializable
data class SignDocResponse(
@SerialName("DocumentWithSignature")
val documentWithSignature: List<String>?,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package at.asitplus.rqes.serializers

import at.asitplus.dif.DifInputDescriptor
import at.asitplus.dif.InputDescriptor
import at.asitplus.rqes.QesInputDescriptor
import at.asitplus.rqes.SignatureResponse
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.json.JsonContentPolymorphicSerializer
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.jsonObject

object SignatureResponseSerializer : JsonContentPolymorphicSerializer<SignatureResponse>(SignatureResponse::class) {
override fun selectDeserializer(element: JsonElement) = when {
"DocumentWithSignature" in element.jsonObject || "SignatureObject" in element.jsonObject || "validationInfo" in element.jsonObject -> SignatureResponse.SignDocResponse.serializer()
override fun selectDeserializer(element: JsonElement): DeserializationStrategy<SignatureResponse> = when {
"DocumentWithSignature" in element.jsonObject || "SignatureObject" in element.jsonObject || "validationInfo" in element.jsonObject -> SignatureResponse.SignDocResponse.serializer() as DeserializationStrategy<SignatureResponse>
else -> SignatureResponse.SignHashResponse.serializer()
}
}

0 comments on commit f028a66

Please sign in to comment.