6161import pl .edu .icm .unity .engine .api .translation .out .TranslationResult ;
6262import pl .edu .icm .unity .engine .api .utils .FreemarkerAppHandler ;
6363import pl .edu .icm .unity .oauth .as .AttributeFilteringSpec ;
64+ import pl .edu .icm .unity .oauth .as .AttributeValueFilter ;
6465import pl .edu .icm .unity .oauth .as .AttributeValueFilterUtils ;
6566import pl .edu .icm .unity .oauth .as .OAuthASProperties ;
6667import pl .edu .icm .unity .oauth .as .OAuthAuthzContext ;
@@ -198,14 +199,16 @@ private void activeValueSelectionAndConsentStage(OAuthAuthzContext ctx, OAuthASP
198199 identity = idpEngine .getIdentity (translationResult , ctx .getConfig ().getSubjectIdentityType ());
199200
200201 Set <DynamicAttribute > allAttributes = OAuthProcessor .filterAttributes (translationResult ,
201- ctx .getEffectiveRequestedAttrs (), ctx .getClaimValueFilters ());
202+ ctx .getEffectiveRequestedAttrs ());
203+
204+ Set <DynamicAttribute > filteredByClaimAttributes = AttributeValueFilter .filterAttributes (ctx .getClaimValueFilters (), allAttributes );
202205
203206 Optional <ActiveValueSelectionConfig > activeValueSelectionConfig = ActiveValueClientHelper
204- .getActiveValueSelectionConfig (config .getActiveValueClients (), ctx .getClientUsername (), allAttributes );
207+ .getActiveValueSelectionConfig (config .getActiveValueClients (), ctx .getClientUsername (), filteredByClaimAttributes );
205208
206209 try
207210 {
208- ACRConsistencyValidator .verifyACRAttribute (ctx , allAttributes );
211+ ACRConsistencyValidator .verifyACRAttribute (ctx , filteredByClaimAttributes );
209212 } catch (OAuthErrorResponseException e )
210213 {
211214 oauthResponseHandler .returnOauthResponseNotThrowingAndReportStatistic (e .getOauthResponse (), false , ctx ,
@@ -214,19 +217,18 @@ private void activeValueSelectionAndConsentStage(OAuthAuthzContext ctx, OAuthASP
214217 }
215218
216219 if (activeValueSelectionConfig .isPresent ())
217- showActiveValueSelectionScreen (activeValueSelectionConfig .get ());
220+ showActiveValueSelectionScreen (activeValueSelectionConfig .get (), ctx );
218221 else
219- gotoConsentStage (allAttributes , null );
222+ gotoConsentStage (allAttributes , null , ctx );
220223 }
221224
222- private void gotoConsentStage (Collection <DynamicAttribute > attributes , Collection <DynamicAttribute > filteredAttributes )
225+ private void gotoConsentStage (Collection <DynamicAttribute > attributes , Collection <DynamicAttribute > filteredAttributes , OAuthAuthzContext context )
223226 {
224- OAuthAuthzContext context = OAuthSessionService .getVaadinContext ();
225227 if (!forceConsentIfConsentPrompt (context ))
226228 {
227229 if (context .getConfig ().isSkipConsent ())
228230 {
229- onFinalConfirm (identity , attributes , filteredAttributes );
231+ onFinalConfirm (identity , AttributeValueFilter . filterAttributes ( context . getClaimValueFilters (), attributes ) , filteredAttributes );
230232 return ;
231233 } else if (isNonePrompt (context ))
232234 {
@@ -236,7 +238,7 @@ private void gotoConsentStage(Collection<DynamicAttribute> attributes, Collectio
236238 }
237239 OAuthConsentScreen consentScreen = new OAuthConsentScreen (msg , handlersRegistry , preferencesMan ,
238240 authnProcessor , idTypeSupport , aTypeSupport , identity , attributes ,
239- this ::onDecline , (i ,a ) -> onFinalConfirm (i , a , filteredAttributes ), oauthResponseHandler );
241+ this ::onDecline , (i ,a ) -> onFinalConfirm (i , AttributeValueFilter . filterAttributes ( context . getClaimValueFilters (), a ) , filteredAttributes ), oauthResponseHandler );
240242 getContent ().removeAll ();
241243 getContent ().add (consentScreen );
242244 }
@@ -260,11 +262,11 @@ private boolean forceConsentIfConsentPrompt(OAuthAuthzContext oauthCtx)
260262 return oauthCtx .getPrompts ().contains (Prompt .CONSENT );
261263 }
262264
263- private void showActiveValueSelectionScreen (ActiveValueSelectionConfig config )
265+ private void showActiveValueSelectionScreen (ActiveValueSelectionConfig config , OAuthAuthzContext ctx )
264266 {
265267 ActiveValueSelectionScreen valueSelectionScreen = new ActiveValueSelectionScreen (msg , handlersRegistry ,
266268 authnProcessor , config .singleSelectableAttributes , config .multiSelectableAttributes ,
267- config .remainingAttributes , OAUTH_CONSENT_DECIDER_SERVLET_PATH , this ::onDecline , (selectionResult ) -> gotoConsentStage (selectionResult .allAttributes (), selectionResult .filteredAttributes ()));
269+ config .remainingAttributes , OAUTH_CONSENT_DECIDER_SERVLET_PATH , this ::onDecline , (selectionResult ) -> gotoConsentStage (selectionResult .allAttributes (), selectionResult .filteredAttributes (), ctx ));
268270 getContent ().removeAll ();
269271 getContent ().add (valueSelectionScreen );
270272 }
0 commit comments