@@ -64,6 +64,7 @@ cJSON *MatchCredential(cJSON *credential, cJSON *credential_store)
64
64
cJSON * cred_auth_json = cJSON_Parse (decoded_cred_auth_json );
65
65
if (!cJSON_HasObjectItem (cred_auth_json , "iss" ))
66
66
{
67
+ printf ("The dcql request has no iss value. No match. \n" );
67
68
return matched_credentials ;
68
69
}
69
70
cJSON * iss_value = cJSON_GetObjectItemCaseSensitive (cred_auth_json , "iss" );
@@ -81,13 +82,15 @@ cJSON *MatchCredential(cJSON *credential, cJSON *credential_store)
81
82
cJSON * iss_allowlist = cJSON_GetObjectItemCaseSensitive (curr_candidate , "iss_allowlist" );
82
83
if (iss_allowlist == NULL )
83
84
{
85
+ printf ("A candidate credential of type %s passed null iss allowlist check.\n" , cJSON_GetStringValue (vct_value ));
84
86
cJSON_AddItemReferenceToArray (candidates , curr_candidate );
85
87
}
86
88
else
87
89
{
88
90
cJSON * allowed_iss ;
89
91
cJSON_ArrayForEach (allowed_iss , iss_allowlist ) {
90
92
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 ));
91
94
cJSON_AddItemReferenceToArray (candidates , curr_candidate );
92
95
break ;
93
96
}
@@ -97,13 +100,17 @@ cJSON *MatchCredential(cJSON *credential, cJSON *credential_store)
97
100
}
98
101
if (cJSON_HasObjectItem (cred_auth_json , "consent_data" ))
99
102
{
103
+ printf ("Request has consent data\n" );
100
104
char * consent_data = cJSON_GetStringValue (cJSON_GetObjectItemCaseSensitive (cred_auth_json , "consent_data" ));
101
105
char * decoded_consent_data_json ;
102
106
int decoded_consent_data_json_len = B64DecodeURL (consent_data , & decoded_consent_data_json );
103
107
cJSON * consent_data_json = cJSON_Parse (decoded_consent_data_json );
104
108
aggregator_consent = cJSON_GetObjectItemCaseSensitive (consent_data_json , "consent_text" );
109
+ printf ("aggregator_consent %s\n" , cJSON_Print (aggregator_consent ));
105
110
aggregator_policy_url = cJSON_GetObjectItemCaseSensitive (consent_data_json , "policy_link" );
111
+ printf ("aggregator_policy_url %s\n" , cJSON_Print (aggregator_policy_url ));
106
112
aggregator_policy_text = cJSON_GetObjectItemCaseSensitive (consent_data_json , "policy_text" );
113
+ printf ("aggregator_policy_text %s\n" , cJSON_Print (aggregator_policy_text ));
107
114
}
108
115
}
109
116
else
@@ -124,6 +131,7 @@ cJSON *MatchCredential(cJSON *credential, cJSON *credential_store)
124
131
// Match on the claims
125
132
if (claims == NULL )
126
133
{
134
+ printf ("No claims provided, matching on the whole credential.\n" );
127
135
// Match every candidate
128
136
cJSON * candidate ;
129
137
cJSON_ArrayForEach (candidate , candidates )
@@ -148,6 +156,7 @@ cJSON *MatchCredential(cJSON *credential, cJSON *credential_store)
148
156
{
149
157
if (claim_sets == NULL )
150
158
{
159
+ printf ("Matching based on provided claims\n" );
151
160
cJSON * candidate ;
152
161
cJSON_ArrayForEach (candidate , candidates )
153
162
{
@@ -173,15 +182,19 @@ cJSON *MatchCredential(cJSON *credential, cJSON *credential_store)
173
182
cJSON * curr_path ;
174
183
cJSON * curr_claim = candidate_claims ;
175
184
int matched = 1 ;
185
+ printf ("Credential claim: %s " , cJSON_Print (curr_claim ));
176
186
cJSON_ArrayForEach (curr_path , paths )
177
187
{
188
+ printf ("- requested path %s " , cJSON_Print (curr_path ));
178
189
char * path_value = cJSON_GetStringValue (curr_path );
179
190
if (cJSON_HasObjectItem (curr_claim , path_value ))
180
191
{
192
+ printf ("- path found " );
181
193
curr_claim = cJSON_GetObjectItemCaseSensitive (curr_claim , path_value );
182
194
}
183
195
else
184
196
{
197
+ printf ("- path not found " );
185
198
matched = 0 ;
186
199
break ;
187
200
}
@@ -195,26 +208,34 @@ cJSON *MatchCredential(cJSON *credential, cJSON *credential_store)
195
208
{
196
209
if (cJSON_Compare (v , cJSON_GetObjectItemCaseSensitive (curr_claim , "value" ), cJSON_True ))
197
210
{
211
+ printf ("- claim value matched.\n" );
198
212
++ matched_claim_count ;
199
213
break ;
200
214
}
201
215
}
202
216
}
203
217
else
204
218
{
219
+ printf ("- claim matched.\n" );
205
220
++ matched_claim_count ;
206
221
}
222
+ } else {
223
+ printf ("- claim did not match\n." );
207
224
}
208
225
}
209
226
cJSON_AddItemReferenceToObject (matched_credential , "matched_claim_names" , matched_claim_names );
210
227
if (matched_claim_count == cJSON_GetArraySize (claims ))
211
228
{
229
+ printf ("Cred matched.\n" );
212
230
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 ));
213
233
}
214
234
}
215
235
}
216
236
else
217
237
{
238
+ printf ("Matching based on provided claims and claim_sets\n" );
218
239
cJSON * candidate ;
219
240
cJSON_ArrayForEach (candidate , candidates )
220
241
{
@@ -325,5 +346,7 @@ cJSON *dcql_query(cJSON *query, cJSON *credential_store)
325
346
matched_credentials = candidate_matched_credentials ;
326
347
}
327
348
}
349
+
350
+ printf ("dcql_query return: %s\n" , cJSON_Print (matched_credentials ));
328
351
return matched_credentials ;
329
352
}
0 commit comments