-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[INJIMOB-2799]: add support for sharing wallet metadata to the verifier #43
Open
Alka1703
wants to merge
3
commits into
mosip:develop
Choose a base branch
from
tw-mosip:injimob-2799-wallet-metadata-share
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
7 changes: 2 additions & 5 deletions
7
...ava/io/mosip/openID4VP/authorizationRequest/proofJwt/handlerFactory/TypeHandlerFactory.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
149 changes: 149 additions & 0 deletions
149
kotlin/openID4VP/src/main/java/io/mosip/openID4VP/dto/WalletMetadata.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,149 @@ | ||
|
||
package io.mosip.openID4VP.dto | ||
|
||
import Generated | ||
import io.mosip.openID4VP.authorizationRequest.ClientIdScheme | ||
import io.mosip.openID4VP.authorizationRequest.Validatable | ||
import io.mosip.openID4VP.common.FieldDeserializer | ||
import io.mosip.openID4VP.common.Logger | ||
import kotlinx.serialization.KSerializer | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.builtins.ListSerializer | ||
import kotlinx.serialization.builtins.serializer | ||
import kotlinx.serialization.descriptors.SerialDescriptor | ||
import kotlinx.serialization.descriptors.buildClassSerialDescriptor | ||
import kotlinx.serialization.descriptors.element | ||
import kotlinx.serialization.encoding.Decoder | ||
import kotlinx.serialization.encoding.Encoder | ||
import kotlinx.serialization.json.JsonDecoder | ||
import kotlinx.serialization.json.jsonObject | ||
|
||
private val className = WalletMetadata::class.simpleName!! | ||
|
||
object WalletMetadataSerializer : KSerializer<WalletMetadata> { | ||
override val descriptor: SerialDescriptor = buildClassSerialDescriptor("ClientMetadata") { | ||
element<Boolean>("presentation_definition_uri_supported", isOptional = true) | ||
element<Map<String,VPFormatSupported>>("vp_formats_supported", isOptional = false) | ||
element<List<String>>("client_id_schemes_supported", isOptional = true) | ||
element<List<String>>("request_object_signing_alg_values_supported", isOptional = true) | ||
element<List<String>>("authorization_encryption_alg_values_supported", isOptional = true) | ||
element<List<String>>("authorization_encryption_enc_values_supported", isOptional = true) | ||
} | ||
|
||
override fun deserialize(decoder: Decoder): WalletMetadata { | ||
val jsonDecoder = try { | ||
decoder as JsonDecoder | ||
} catch (e: ClassCastException) { | ||
throw Logger.handleException( | ||
exceptionType = "DeserializationFailure", | ||
fieldPath = listOf("wallet_metadata"), | ||
message = e.message!!, | ||
className = className | ||
) | ||
} | ||
val jsonObject = jsonDecoder.decodeJsonElement().jsonObject | ||
val deserializer = FieldDeserializer( | ||
jsonObject = jsonObject, | ||
className = className, | ||
parentField = "wallet_metadata" | ||
) | ||
|
||
val presentationDefinitionURISupported: Boolean? = | ||
deserializer.deserializeField( | ||
key = "presentation_definition_uri_supported", | ||
fieldType = "Boolean" | ||
) | ||
val vpFormatsSupported: Map<String, VPFormatSupported> = | ||
deserializer.deserializeField(key = "vp_formats_supported", fieldType = "Map", isMandatory = true) | ||
?: throw Logger.handleException( | ||
exceptionType = "InvalidInput", | ||
fieldPath = listOf("wallet_metadata", "vp_formats_supported"), | ||
className = className, | ||
fieldType = "map", | ||
) | ||
val clientIdSchemesSupported: List<String>? = | ||
deserializer.deserializeField(key = "client_id_schemes_supported", fieldType = "List") | ||
val requestObjectSigningAlgValuesSupported: List<String>? = | ||
deserializer.deserializeField(key = "request_object_signing_alg_values_supported", fieldType = "List") | ||
val authorizationEncryptionAlgValuesSupported: List<String>? = | ||
deserializer.deserializeField(key = "authorization_encryption_alg_values_supported", fieldType = "List") | ||
val authorizationEncryptionEncValuesSupported: List<String>? = | ||
deserializer.deserializeField(key = "authorization_encryption_enc_values_supported", fieldType = "List") | ||
|
||
return WalletMetadata( | ||
presentationDefinitionURISupported = presentationDefinitionURISupported, | ||
vpFormatsSupported = vpFormatsSupported, | ||
clientIdSchemesSupported = clientIdSchemesSupported, | ||
requestObjectSigningAlgValuesSupported = requestObjectSigningAlgValuesSupported, | ||
authorizationEncryptionAlgValuesSupported = authorizationEncryptionAlgValuesSupported, | ||
authorizationEncryptionEncValuesSupported = authorizationEncryptionEncValuesSupported | ||
) | ||
} | ||
|
||
@Generated | ||
override fun serialize(encoder: Encoder, value: WalletMetadata) { | ||
val builtInEncoder = encoder.beginStructure(descriptor) | ||
|
||
value.presentationDefinitionURISupported?.let { | ||
builtInEncoder.encodeBooleanElement( | ||
descriptor, | ||
0, | ||
it | ||
) | ||
} | ||
value.clientIdSchemesSupported?.let { | ||
builtInEncoder.encodeSerializableElement( | ||
descriptor, | ||
2, | ||
ListSerializer(String.serializer()), | ||
it | ||
) | ||
} | ||
value.requestObjectSigningAlgValuesSupported?.let { | ||
builtInEncoder.encodeSerializableElement( | ||
descriptor, | ||
3, | ||
ListSerializer(String.serializer()), | ||
it | ||
) | ||
} | ||
value.authorizationEncryptionAlgValuesSupported?.let { | ||
builtInEncoder.encodeSerializableElement( | ||
descriptor, | ||
4, | ||
ListSerializer(String.serializer()), | ||
it | ||
) | ||
} | ||
value.authorizationEncryptionEncValuesSupported?.let { | ||
builtInEncoder.encodeSerializableElement( | ||
descriptor, | ||
4, | ||
ListSerializer(String.serializer()), | ||
it | ||
) | ||
} | ||
builtInEncoder.endStructure(descriptor) | ||
} | ||
} | ||
|
||
@Serializable(with = WalletMetadataSerializer::class) | ||
class WalletMetadata( | ||
|
||
@SerialName("presentation_definition_uri_supported") val presentationDefinitionURISupported: Boolean? = true, | ||
@SerialName("vp_formats_supported") val vpFormatsSupported: Map<String, VPFormatSupported>, | ||
@SerialName("client_id_schemes_supported")val clientIdSchemesSupported: List<String>? = listOf(ClientIdScheme.PRE_REGISTERED.value), | ||
@SerialName("request_object_signing_alg_values_supported") val requestObjectSigningAlgValuesSupported: List<String>? = null, | ||
@SerialName("authorization_encryption_alg_values_supported") val authorizationEncryptionAlgValuesSupported: List<String>? = null, | ||
@SerialName("authorization_encryption_enc_values_supported") val authorizationEncryptionEncValuesSupported: List<String>? = null | ||
) : Validatable { | ||
override fun validate() { | ||
} | ||
} | ||
@Serializable | ||
data class VPFormatSupported( | ||
@SerialName("alg_values_supported") val algValuesSupported: List<String>? | ||
) | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we alos add Readme update for the new feature introduced?