From 124ea120adef184e30f663a568f49b578fb7cd5f Mon Sep 17 00:00:00 2001 From: "Josep Milan K.A" Date: Mon, 4 Nov 2024 13:08:57 +0530 Subject: [PATCH] Fix: Added function to check credential metadata present or not --- .../services/issue/IssueService.kt | 30 +++++++++++++++++++ .../services/issue/IssueServiceInterface.kt | 6 ++++ 2 files changed, 36 insertions(+) diff --git a/eudi-wallet-oidc-android/src/main/java/com/ewc/eudi_wallet_oidc_android/services/issue/IssueService.kt b/eudi-wallet-oidc-android/src/main/java/com/ewc/eudi_wallet_oidc_android/services/issue/IssueService.kt index 413c88d..be9351f 100644 --- a/eudi-wallet-oidc-android/src/main/java/com/ewc/eudi_wallet_oidc_android/services/issue/IssueService.kt +++ b/eudi-wallet-oidc-android/src/main/java/com/ewc/eudi_wallet_oidc_android/services/issue/IssueService.kt @@ -1068,4 +1068,34 @@ class IssueService : IssueServiceInterface { return types } + + override fun isCredentialMetaDataAvailable( + issuerConfig: IssuerWellKnownConfiguration?, + type: String?, + version: Int? + ): Boolean { + try { + val credentialOfferJsonString = Gson().toJson(issuerConfig) + // Check if credentialOfferJsonString is null or empty + if (credentialOfferJsonString.isNullOrEmpty()) { + return false + } + val jsonObject = JSONObject(credentialOfferJsonString) + + val credentialsSupported: Any = + jsonObject.opt("credentials_supported") ?: return false + when (credentialsSupported) { + is JSONObject -> { + try { + return credentialsSupported.has(type ?: "") + } catch (e: Exception) { + return false + } + } + } + } catch (e: Exception) { + + } + return false + } } \ No newline at end of file diff --git a/eudi-wallet-oidc-android/src/main/java/com/ewc/eudi_wallet_oidc_android/services/issue/IssueServiceInterface.kt b/eudi-wallet-oidc-android/src/main/java/com/ewc/eudi_wallet_oidc_android/services/issue/IssueServiceInterface.kt index c9f8c6f..093017d 100644 --- a/eudi-wallet-oidc-android/src/main/java/com/ewc/eudi_wallet_oidc_android/services/issue/IssueServiceInterface.kt +++ b/eudi-wallet-oidc-android/src/main/java/com/ewc/eudi_wallet_oidc_android/services/issue/IssueServiceInterface.kt @@ -158,4 +158,10 @@ interface IssueServiceInterface { issuerConfig: IssuerWellKnownConfiguration?, type: String? ): ArrayList? + + fun isCredentialMetaDataAvailable( + issuerConfig: IssuerWellKnownConfiguration?, + type: String?, + version: Int? = 2 + ): Boolean } \ No newline at end of file