Skip to content

Commit

Permalink
Fix: Added function to check credential metadata present or not
Browse files Browse the repository at this point in the history
  • Loading branch information
josmilan authored Nov 4, 2024
1 parent 32ac087 commit 124ea12
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,10 @@ interface IssueServiceInterface {
issuerConfig: IssuerWellKnownConfiguration?,
type: String?
): ArrayList<String>?

fun isCredentialMetaDataAvailable(
issuerConfig: IssuerWellKnownConfiguration?,
type: String?,
version: Int? = 2
): Boolean
}

0 comments on commit 124ea12

Please sign in to comment.