Skip to content

Commit 443bcca

Browse files
committed
UY-1520 CR-1308 fixes
1 parent bbe56e4 commit 443bcca

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

oauth/src/main/java/pl/edu/icm/unity/oauth/as/webauthz/ASConsentDeciderServlet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ protected void autoReplay(OAuthClientSettings clientPreferences, OAuthAuthzConte
213213
Collection<DynamicAttribute> attributes = OAuthProcessor.filterAttributes(userInfo,
214214
oauthCtx.getEffectiveRequestedAttrs());
215215
Set<DynamicAttribute> filteredAttributes = AttributeValueFilter.filterAttributes(oauthCtx.getClaimValueFilters(), attributes);
216-
ACRConsistencyValidator.verifyACRAttribute(oauthCtx, filteredAttributes);
216+
EssentialACRConsistencyValidator.verifyEssentialRequestedACRisReturned(oauthCtx, filteredAttributes);
217217
respDoc = oauthProcessor.prepareAuthzResponseAndRecordInternalState(filteredAttributes, selectedIdentity, oauthCtx,
218218
statReporter, InvocationContext.getCurrent().getLoginSession().getAuthenticationTime(), oauthCtx.getClaimValueFilters());
219219
} catch (OAuthErrorResponseException e)

oauth/src/main/java/pl/edu/icm/unity/oauth/as/webauthz/ACRConsistencyValidator.java renamed to oauth/src/main/java/pl/edu/icm/unity/oauth/as/webauthz/EssentialACRConsistencyValidator.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@
1818
import pl.edu.icm.unity.oauth.as.OAuthAuthzContext;
1919
import pl.edu.icm.unity.oauth.as.OAuthErrorResponseException;
2020

21-
public class ACRConsistencyValidator
21+
public class EssentialACRConsistencyValidator
2222
{
23-
static void verifyACRAttribute(OAuthAuthzContext ctx, Collection<DynamicAttribute> attributes) throws OAuthErrorResponseException
23+
static void verifyEssentialRequestedACRisReturned(OAuthAuthzContext ctx, Collection<DynamicAttribute> attributes) throws OAuthErrorResponseException
2424
{
2525
if (ctx.getAcr().isEmpty())
2626
return;
2727
if (ctx.getAcr().getEssentialACRs() == null || ctx.getAcr().getEssentialACRs().isEmpty())
2828
return;
29-
Optional<DynamicAttribute> any = attributes.stream().filter(a -> a.getAttribute().getName().equals(IDTokenClaimsSet.ACR_CLAIM_NAME)).findAny();
29+
Optional<DynamicAttribute> acrAttribute = attributes.stream().filter(a -> a.getAttribute().getName().equals(IDTokenClaimsSet.ACR_CLAIM_NAME)).findAny();
3030

31-
if (any.isPresent())
31+
if (acrAttribute.isPresent())
3232
{
33-
if (any.get().getAttribute().getValues().containsAll(ctx.getAcr().getEssentialACRs().stream().map(acr -> acr.getValue()).toList()))
33+
if (acrAttribute.get().getAttribute().getValues().containsAll(ctx.getAcr().getEssentialACRs().stream().map(acr -> acr.getValue()).toList()))
3434
return;
3535
}
3636

oauth/src/main/java/pl/edu/icm/unity/oauth/as/webauthz/OAuthAuthzView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ private void activeValueSelectionAndConsentStage(OAuthAuthzContext ctx, OAuthASP
208208

209209
try
210210
{
211-
ACRConsistencyValidator.verifyACRAttribute(ctx, filteredByClaimAttributes);
211+
EssentialACRConsistencyValidator.verifyEssentialRequestedACRisReturned(ctx, filteredByClaimAttributes);
212212
} catch (OAuthErrorResponseException e)
213213
{
214214
oauthResponseHandler.returnOauthResponseNotThrowingAndReportStatistic(e.getOauthResponse(), false, ctx,

oauth/src/test/java/pl/edu/icm/unity/oauth/as/webauthz/ACRConsistencyValidatorTest.java renamed to oauth/src/test/java/pl/edu/icm/unity/oauth/as/webauthz/EssentialACRConsistencyValidatorTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import pl.edu.icm.unity.oauth.as.OAuthAuthzContext;
2626
import pl.edu.icm.unity.oauth.as.OAuthErrorResponseException;
2727

28-
public class ACRConsistencyValidatorTest
28+
public class EssentialACRConsistencyValidatorTest
2929
{
3030
@Test
3131
public void shouldThrowExceptionWhenReturnedACRNotContainsRequestedACR() throws OAuthErrorResponseException, URISyntaxException
@@ -34,7 +34,7 @@ public void shouldThrowExceptionWhenReturnedACRNotContainsRequestedACR() throws
3434
context.setAcr(new ACRRequest(List.of(new ACR("essentialACR1")), null));
3535
context.setReturnURI(new URI("return"));
3636
List<DynamicAttribute> attrs = List.of(new DynamicAttribute(new Attribute("acr", null, null, List.of("acr1"))));
37-
assertThrows(OAuthErrorResponseException.class, () -> ACRConsistencyValidator.verifyACRAttribute(context, attrs));
37+
assertThrows(OAuthErrorResponseException.class, () -> EssentialACRConsistencyValidator.verifyEssentialRequestedACRisReturned(context, attrs));
3838
}
3939

4040
@Test
@@ -44,7 +44,7 @@ public void shouldValidateSuccessfulltWhenACRContainsRequestedACR() throws OAuth
4444
context.setAcr(new ACRRequest(List.of(new ACR("essentialACR1")), null));
4545
context.setReturnURI(new URI("return"));
4646
List<DynamicAttribute> attrs = List.of(new DynamicAttribute(new Attribute("acr", null, null, List.of("essentialACR1"))));
47-
assertDoesNotThrow(() -> ACRConsistencyValidator.verifyACRAttribute(context, attrs));
47+
assertDoesNotThrow(() -> EssentialACRConsistencyValidator.verifyEssentialRequestedACRisReturned(context, attrs));
4848
}
4949

5050
@Test
@@ -54,6 +54,6 @@ public void shouldValidateSuccessfulltWhenRequestedACRisVoluntary() throws OAuth
5454
context.setAcr(new ACRRequest(List.of(), List.of(new ACR("voluntaryACR1"))));
5555
context.setReturnURI(new URI("return"));
5656
List<DynamicAttribute> attrs = List.of(new DynamicAttribute(new Attribute("acr", null, null, List.of("anotherACR"))));
57-
assertDoesNotThrow(() -> ACRConsistencyValidator.verifyACRAttribute(context, attrs));
57+
assertDoesNotThrow(() -> EssentialACRConsistencyValidator.verifyEssentialRequestedACRisReturned(context, attrs));
5858
}
5959
}

0 commit comments

Comments
 (0)