-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parse vci request and prepare for credential endpoint call.
Note the credential endpoint part is neither tested nor invoked for now.
- Loading branch information
Showing
8 changed files
with
161 additions
and
12 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
49 changes: 49 additions & 0 deletions
49
app/src/main/java/com/credman/cmwallet/openid4vci/CredentialEndpointDataModel.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,49 @@ | ||
package com.credman.cmwallet.openid4vci | ||
|
||
import android.util.Log | ||
import com.credman.cmwallet.CmWalletApplication.Companion.TAG | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.encodeToString | ||
import kotlinx.serialization.json.Json | ||
|
||
internal val jsonFormat = Json { explicitNulls = false } | ||
|
||
fun String.toCredentialResponse(): CredentialResponse? { | ||
return try { | ||
jsonFormat.decodeFromString<CredentialResponse>(this) | ||
} catch (e: Exception) { | ||
Log.e(TAG, "credential response parsing exception", e) | ||
null | ||
} | ||
} | ||
|
||
@Serializable | ||
data class CredentialResponse( | ||
val credentials: List<Credential>? = null, | ||
val transaction_id: String? = null, | ||
val notification_id: String? = null, | ||
) | ||
|
||
@Serializable | ||
data class Credential( | ||
// Technically this could also be an object | ||
val credential: String, | ||
) | ||
|
||
@Serializable | ||
data class CredentialRequest( | ||
val credential_configuration_id: String, | ||
val proof: Proof? = null, | ||
) { | ||
fun toJson(): String { | ||
return jsonFormat.encodeToString(this) | ||
} | ||
} | ||
|
||
@Serializable | ||
class Proof( | ||
val proof_type: String, | ||
val jwt: String?, | ||
) | ||
|
||
internal const val JWT = "jwt" |
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