Skip to content

Commit

Permalink
Fix #24: filter logic updated with limited_disclosures parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
josmilan committed May 28, 2024
1 parent ee56ae7 commit ca4b78a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ data class InputDescriptors(

data class Constraints(

@SerializedName("limit_disclosure") var limitDisclosure: String? = null,
@SerializedName("fields") var fields: ArrayList<Fields>? = null

)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,24 +435,30 @@ class IssueService : IssueServiceInterface {

when (credentialsSupported) {
is JSONObject -> {
val credentialSupported = credentialsSupported.getJSONObject(type ?: "")
format = credentialSupported.getString("format")
try {
val credentialSupported = credentialsSupported.getJSONObject(type ?: "")
format = credentialSupported.getString("format")
} catch (e: Exception) {
}
}

is JSONArray -> {
for (i in 0 until credentialsSupported.length()) {
val jsonObject: JSONObject = credentialsSupported.getJSONObject(i)

// Get the "types" JSONArray
val typesArray = jsonObject.getJSONArray("types")

// Check if the string is present in the "types" array
for (j in 0 until typesArray.length()) {
if (typesArray.getString(j) == type) {
format = jsonObject.getString("format")
break
try {
for (i in 0 until credentialsSupported.length()) {
val jsonObject: JSONObject = credentialsSupported.getJSONObject(i)

// Get the "types" JSONArray
val typesArray = jsonObject.getJSONArray("types")

// Check if the string is present in the "types" array
for (j in 0 until typesArray.length()) {
if (typesArray.getString(j) == type) {
format = jsonObject.getString("format")
break
}
}
}
} catch (e: Exception) {
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class VerificationService : VerificationServiceInterface {
)

return json
}else{
} else {
return null
}
} else {
Expand Down Expand Up @@ -194,10 +194,25 @@ class VerificationService : VerificationServiceInterface {
* Returns all the list of credentials matching for all input descriptors
*/
override suspend fun filterCredentials(
credentialList: List<String?>,
allCredentialList: List<String?>,
presentationDefinition: PresentationDefinition
): List<List<String>> {
//list of credentials matched for all input descriptors

val credentialList: ArrayList<String?> = arrayListOf()
for (item in allCredentialList) {
if (presentationDefinition.inputDescriptors?.get(0)?.constraints?.limitDisclosure != null && item?.contains(
"~"
) == true
)
credentialList.add(item)
else if (presentationDefinition.inputDescriptors?.get(0)?.constraints?.limitDisclosure == null && item?.contains(
"~"
) != true
)
credentialList.add(item)
}

val response: MutableList<MutableList<String>> = mutableListOf()

var processedCredentials: List<String> = mutableListOf()
Expand Down

0 comments on commit ca4b78a

Please sign in to comment.