Skip to content

Commit 0536123

Browse files
committed
Add more logging to matcher
1 parent 72838b7 commit 0536123

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

app/src/main/assets/pnv.wasm

1.6 KB
Binary file not shown.

matcher/pnv/dcql.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ cJSON *MatchCredential(cJSON *credential, cJSON *credential_store)
6464
cJSON *cred_auth_json = cJSON_Parse(decoded_cred_auth_json);
6565
if (!cJSON_HasObjectItem(cred_auth_json, "iss"))
6666
{
67+
printf("The dcql request has no iss value. No match. \n");
6768
return matched_credentials;
6869
}
6970
cJSON *iss_value = cJSON_GetObjectItemCaseSensitive(cred_auth_json, "iss");
@@ -81,13 +82,15 @@ cJSON *MatchCredential(cJSON *credential, cJSON *credential_store)
8182
cJSON *iss_allowlist = cJSON_GetObjectItemCaseSensitive(curr_candidate, "iss_allowlist");
8283
if (iss_allowlist == NULL)
8384
{
85+
printf("A candidate credential of type %s passed null iss allowlist check.\n", cJSON_GetStringValue(vct_value));
8486
cJSON_AddItemReferenceToArray(candidates, curr_candidate);
8587
}
8688
else
8789
{
8890
cJSON *allowed_iss;
8991
cJSON_ArrayForEach(allowed_iss, iss_allowlist) {
9092
if (cJSON_Compare(allowed_iss, iss_value, cJSON_True)) {
93+
printf("A candidate credential of type %s passed iss allowlist check.\n", cJSON_GetStringValue(vct_value));
9194
cJSON_AddItemReferenceToArray(candidates, curr_candidate);
9295
break;
9396
}
@@ -97,13 +100,17 @@ cJSON *MatchCredential(cJSON *credential, cJSON *credential_store)
97100
}
98101
if (cJSON_HasObjectItem(cred_auth_json, "consent_data"))
99102
{
103+
printf("Request has consent data\n");
100104
char *consent_data = cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(cred_auth_json, "consent_data"));
101105
char *decoded_consent_data_json;
102106
int decoded_consent_data_json_len = B64DecodeURL(consent_data, &decoded_consent_data_json);
103107
cJSON *consent_data_json = cJSON_Parse(decoded_consent_data_json);
104108
aggregator_consent = cJSON_GetObjectItemCaseSensitive(consent_data_json, "consent_text");
109+
printf("aggregator_consent %s\n", cJSON_Print(aggregator_consent));
105110
aggregator_policy_url = cJSON_GetObjectItemCaseSensitive(consent_data_json, "policy_link");
111+
printf("aggregator_policy_url %s\n", cJSON_Print(aggregator_policy_url));
106112
aggregator_policy_text = cJSON_GetObjectItemCaseSensitive(consent_data_json, "policy_text");
113+
printf("aggregator_policy_text %s\n", cJSON_Print(aggregator_policy_text));
107114
}
108115
}
109116
else
@@ -124,6 +131,7 @@ cJSON *MatchCredential(cJSON *credential, cJSON *credential_store)
124131
// Match on the claims
125132
if (claims == NULL)
126133
{
134+
printf("No claims provided, matching on the whole credential.\n");
127135
// Match every candidate
128136
cJSON *candidate;
129137
cJSON_ArrayForEach(candidate, candidates)
@@ -148,6 +156,7 @@ cJSON *MatchCredential(cJSON *credential, cJSON *credential_store)
148156
{
149157
if (claim_sets == NULL)
150158
{
159+
printf("Matching based on provided claims\n");
151160
cJSON *candidate;
152161
cJSON_ArrayForEach(candidate, candidates)
153162
{
@@ -173,15 +182,19 @@ cJSON *MatchCredential(cJSON *credential, cJSON *credential_store)
173182
cJSON *curr_path;
174183
cJSON *curr_claim = candidate_claims;
175184
int matched = 1;
185+
printf("Credential claim: %s ", cJSON_Print(curr_claim));
176186
cJSON_ArrayForEach(curr_path, paths)
177187
{
188+
printf("- requested path %s ", cJSON_Print(curr_path));
178189
char *path_value = cJSON_GetStringValue(curr_path);
179190
if (cJSON_HasObjectItem(curr_claim, path_value))
180191
{
192+
printf("- path found ");
181193
curr_claim = cJSON_GetObjectItemCaseSensitive(curr_claim, path_value);
182194
}
183195
else
184196
{
197+
printf("- path not found ");
185198
matched = 0;
186199
break;
187200
}
@@ -195,26 +208,34 @@ cJSON *MatchCredential(cJSON *credential, cJSON *credential_store)
195208
{
196209
if (cJSON_Compare(v, cJSON_GetObjectItemCaseSensitive(curr_claim, "value"), cJSON_True))
197210
{
211+
printf("- claim value matched.\n");
198212
++matched_claim_count;
199213
break;
200214
}
201215
}
202216
}
203217
else
204218
{
219+
printf("- claim matched.\n");
205220
++matched_claim_count;
206221
}
222+
} else {
223+
printf("- claim did not match\n.");
207224
}
208225
}
209226
cJSON_AddItemReferenceToObject(matched_credential, "matched_claim_names", matched_claim_names);
210227
if (matched_claim_count == cJSON_GetArraySize(claims))
211228
{
229+
printf("Cred matched.\n");
212230
cJSON_AddItemReferenceToArray(matched_credentials, matched_credential);
231+
} else {
232+
printf("Cred did not match. Matched claim count: %d, Expected match count: %d\n.", matched_claim_count, cJSON_GetArraySize(claims));
213233
}
214234
}
215235
}
216236
else
217237
{
238+
printf("Matching based on provided claims and claim_sets\n");
218239
cJSON *candidate;
219240
cJSON_ArrayForEach(candidate, candidates)
220241
{
@@ -325,5 +346,7 @@ cJSON *dcql_query(cJSON *query, cJSON *credential_store)
325346
matched_credentials = candidate_matched_credentials;
326347
}
327348
}
349+
350+
printf("dcql_query return: %s\n", cJSON_Print(matched_credentials));
328351
return matched_credentials;
329352
}

matcher/pnv/openid4vp1_0.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ int main() {
128128
cJSON* doc_id = cJSON_GetObjectItem(matched_doc, "id");
129129
cJSON* c;
130130
cJSON_ArrayForEach(c, matched_cred) {
131-
// printf("cred %s\n", cJSON_Print(c));
131+
printf("Attempting to add cred %s\n", cJSON_Print(c));
132132
cJSON* id_obj = cJSON_CreateObject();
133133
cJSON* matched_id = cJSON_GetObjectItem(c, "id");
134134

@@ -179,11 +179,13 @@ int main() {
179179
}
180180
}
181181
matched = 1;
182+
printf("AddStringIdEntry %s\n", id);
182183
AddStringIdEntry(id, creds_blob + icon_start_int, icon_len, title, subtitle, disclaimer, NULL);
183184
SetAdditionalDisclaimerAndUrlForVerificationEntry(id, aggregator_consent, aggregator_policy_text, aggregator_policy_url);
184185
cJSON *matched_claim_names = cJSON_GetObjectItem(c, "matched_claim_names");
185186
cJSON *claim;
186187
cJSON_ArrayForEach(claim, matched_claim_names) {
188+
printf("AddFieldForStringIdEntry %s, claim value: %s\n", id, cJSON_Print(claim));
187189
AddFieldForStringIdEntry(id, cJSON_GetStringValue(claim), NULL);
188190
}
189191
}

0 commit comments

Comments
 (0)