@@ -166,15 +166,17 @@ private void executeClientAuthenticators(HttpServletRequest request, OAuthClient
166
166
}
167
167
try {
168
168
List <OAuthClientAuthenticator > configuredClientAuthMethods = getConfiguredClientAuthMethods (clientId );
169
- List <OAuthClientAuthenticator > authenticators = configuredClientAuthMethods ;
169
+ List <OAuthClientAuthenticator > applicableAuthenticators ;
170
170
if (OAuth2Util .isFapiConformantApp (clientId )) {
171
- authenticators = validateAndGetClientAuthenticatorsForFapi (configuredClientAuthMethods );
171
+ applicableAuthenticators = filterClientAuthenticatorsForFapi (configuredClientAuthMethods );
172
172
} else {
173
173
if (configuredClientAuthMethods .isEmpty ()) {
174
- authenticators = this .getClientAuthenticators ();
174
+ applicableAuthenticators = this .getClientAuthenticators ();
175
+ } else {
176
+ applicableAuthenticators = configuredClientAuthMethods ;
175
177
}
176
178
}
177
- if (authenticators .isEmpty ()) {
179
+ if (applicableAuthenticators .isEmpty ()) {
178
180
setErrorToContext (OAuth2ErrorCodes .INVALID_REQUEST , "No valid authenticators found for " +
179
181
"the application." , oAuthClientAuthnContext );
180
182
return ;
@@ -371,22 +373,23 @@ private String extractClientId(HttpServletRequest request, Map<String, List> bod
371
373
* @param configuredAuthenticators List of client authenticators configured for the application.
372
374
* @return List of applicable client authentication methods for the application.
373
375
*/
374
- private List <OAuthClientAuthenticator > validateAndGetClientAuthenticatorsForFapi (
376
+ private List <OAuthClientAuthenticator > filterClientAuthenticatorsForFapi (
375
377
List <OAuthClientAuthenticator > configuredAuthenticators ) {
376
378
377
379
List <String > fapiAllowedAuthMethods = IdentityUtil .getPropertyAsList (FAPI_CLIENT_AUTH_METHOD_CONFIGURATION );
378
380
if (configuredAuthenticators .isEmpty ()) {
379
381
return getApplicableClientAuthenticators (fapiAllowedAuthMethods );
380
382
}
381
383
384
+ List <OAuthClientAuthenticator > filteredAuthenticators = new ArrayList <>();
382
385
for (OAuthClientAuthenticator authenticator : configuredAuthenticators ) {
383
- if (! fapiAllowedAuthMethods .stream ().anyMatch (authenticator
386
+ if (fapiAllowedAuthMethods .stream ().anyMatch (authenticator
384
387
.getSupportedClientAuthenticationMethods ()::contains )) {
385
- return Collections . emptyList ( );
388
+ filteredAuthenticators . add ( authenticator );
386
389
}
387
390
}
388
391
389
- return configuredAuthenticators ;
392
+ return filteredAuthenticators ;
390
393
}
391
394
392
395
/**
0 commit comments