@@ -30,45 +30,107 @@ impl Default for OpenId4VciFilter {
3030
3131impl OpenId4VciFilter {
3232 pub fn matches ( & self , request : & RegularizedOpenId4VciRequestData ) -> bool {
33- match & self {
34- Self :: Unit { } => true ,
35- Self :: And { filters } => filters. iter ( ) . all ( |f| f. matches ( request) ) ,
36- Self :: Or { filters } => filters. iter ( ) . any ( |f| f. matches ( request) ) ,
37- Self :: Not { filter } => !filter. matches ( request) ,
38- Self :: AllowsIssuers { issuers } => issuers. contains ( request. credential_issuer ) ,
39- Self :: AllowsConfigurationIds { configuration_ids } => request
40- . credential_configuration_ids
41- . iter ( )
42- . any ( |id| configuration_ids. contains ( id) ) ,
43- Self :: SupportsAuthCodeFlow { } => request. grants . contains_key ( "authorization_code" ) ,
44- Self :: SupportsPreAuthFlow { } => request
45- . grants
46- . contains_key ( "urn:ietf:params:oauth:grant-type:pre-authorized_code" ) ,
47- Self :: SupportsNonceEndpoint { } => request
48- . credential_issuer_metadata
49- . is_some_and ( |m| !m. nonce_endpoint . is_empty ( ) ) ,
50- Self :: SupportsDeferredCredentialEndpoint { } => request
51- . credential_issuer_metadata
52- . is_some_and ( |m| !m. deferred_credential_endpoint . is_empty ( ) ) ,
53- Self :: SupportsNotificationEndpoint { } => request
54- . credential_issuer_metadata
55- . is_some_and ( |m| !m. notification_endpoint . is_empty ( ) ) ,
33+ let matched = match & self {
34+ Self :: Unit { } => {
35+ log:: trace!( "Filter Unit matched" ) ;
36+ true
37+ }
38+ Self :: And { filters } => {
39+ let res = filters. iter ( ) . all ( |f| f. matches ( request) ) ;
40+ log:: trace!( "Filter And matched: {}" , res) ;
41+ res
42+ }
43+ Self :: Or { filters } => {
44+ let res = filters. iter ( ) . any ( |f| f. matches ( request) ) ;
45+ log:: trace!( "Filter Or matched: {}" , res) ;
46+ res
47+ }
48+ Self :: Not { filter } => {
49+ let res = !filter. matches ( request) ;
50+ log:: trace!( "Filter Not matched: {}" , res) ;
51+ res
52+ }
53+ Self :: AllowsIssuers { issuers } => {
54+ let res = issuers. contains ( request. credential_issuer ) ;
55+ log:: trace!(
56+ "Filter AllowsIssuers (issuer={}) matched: {}" ,
57+ request. credential_issuer,
58+ res
59+ ) ;
60+ res
61+ }
62+ Self :: AllowsConfigurationIds { configuration_ids } => {
63+ let res = request
64+ . credential_configuration_ids
65+ . iter ( )
66+ . any ( |id| configuration_ids. contains ( id) ) ;
67+ log:: trace!( "Filter AllowsConfigurationIds matched: {}" , res) ;
68+ res
69+ }
70+ Self :: SupportsAuthCodeFlow { } => {
71+ let res = request. grants . contains_key ( "authorization_code" ) ;
72+ log:: trace!( "Filter SupportsAuthCodeFlow matched: {}" , res) ;
73+ res
74+ }
75+ Self :: SupportsPreAuthFlow { } => {
76+ let res = request
77+ . grants
78+ . contains_key ( "urn:ietf:params:oauth:grant-type:pre-authorized_code" ) ;
79+ log:: trace!( "Filter SupportsPreAuthFlow matched: {}" , res) ;
80+ res
81+ }
82+ Self :: SupportsNonceEndpoint { } => {
83+ let res = request
84+ . credential_issuer_metadata
85+ . is_some_and ( |m| !m. nonce_endpoint . is_empty ( ) ) ;
86+ log:: trace!( "Filter SupportsNonceEndpoint matched: {}" , res) ;
87+ res
88+ }
89+ Self :: SupportsDeferredCredentialEndpoint { } => {
90+ let res = request
91+ . credential_issuer_metadata
92+ . is_some_and ( |m| !m. deferred_credential_endpoint . is_empty ( ) ) ;
93+ log:: trace!( "Filter SupportsDeferredCredentialEndpoint matched: {}" , res) ;
94+ res
95+ }
96+ Self :: SupportsNotificationEndpoint { } => {
97+ let res = request
98+ . credential_issuer_metadata
99+ . is_some_and ( |m| !m. notification_endpoint . is_empty ( ) ) ;
100+ log:: trace!( "Filter SupportsNotificationEndpoint matched: {}" , res) ;
101+ res
102+ }
56103 Self :: RequiresBatchIssuance { min_batch_size } => {
57- request. credential_issuer_metadata . is_some_and ( |m| {
104+ let res = request. credential_issuer_metadata . is_some_and ( |m| {
58105 m. batch_credential_issuance
59106 . as_ref ( )
60107 . is_some_and ( |b| b. batch_size >= * min_batch_size)
61- } )
108+ } ) ;
109+ log:: trace!(
110+ "Filter RequiresBatchIssuance (min={}) matched: {}" ,
111+ min_batch_size,
112+ res
113+ ) ;
114+ res
115+ }
116+ Self :: SupportsMdocDoctype { doctypes } => {
117+ let res = request
118+ . credential_configurations
119+ . iter ( )
120+ . any ( |c| doctypes. contains ( & c. doctype ) ) ;
121+ log:: trace!( "Filter SupportsMdocDoctype matched: {}" , res) ;
122+ res
123+ }
124+ Self :: SupportsSdJwtVct { vcts } => {
125+ let res = request
126+ . credential_configurations
127+ . iter ( )
128+ . any ( |c| vcts. contains ( & c. vct ) ) ;
129+ log:: trace!( "Filter SupportsSdJwtVct matched: {}" , res) ;
130+ res
62131 }
63- Self :: SupportsMdocDoctype { doctypes } => request
64- . credential_configurations
65- . iter ( )
66- . any ( |c| doctypes. contains ( & c. doctype ) ) ,
67- Self :: SupportsSdJwtVct { vcts } => request
68- . credential_configurations
69- . iter ( )
70- . any ( |c| vcts. contains ( & c. vct ) ) ,
71- }
132+ } ;
133+ matched
72134 }
73135}
74136
0 commit comments