From b62dcc092870e07e0091eac32704369228445929 Mon Sep 17 00:00:00 2001 From: LE Weerasinghe Date: Fri, 14 Feb 2025 17:23:44 +0530 Subject: [PATCH 1/3] Changes to getAMRValues method --- .../endpoint/authz/OAuth2AuthzEndpoint.java | 16 ++++++++++++++++ pom.xml | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzEndpoint.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzEndpoint.java index 8797c15cdcd..6a31296496a 100644 --- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzEndpoint.java +++ b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzEndpoint.java @@ -48,6 +48,7 @@ import org.wso2.carbon.identity.application.authentication.framework.AuthenticatorFlowStatus; import org.wso2.carbon.identity.application.authentication.framework.CommonAuthenticationHandler; import org.wso2.carbon.identity.application.authentication.framework.cache.AuthenticationResultCacheEntry; +import org.wso2.carbon.identity.application.authentication.framework.config.model.AuthenticatorConfig; import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.JsLogger; import org.wso2.carbon.identity.application.authentication.framework.context.AuthHistory; import org.wso2.carbon.identity.application.authentication.framework.context.SessionContext; @@ -4205,6 +4206,21 @@ private void associateAuthenticationHistory(SessionDataCacheEntry resultFromLogi */ private List getAMRValues(List authMethods, Map authenticatedIdPs) { + boolean authenticatorAMREnabled = true; + if (authenticatorAMREnabled) { + List resultantAuthMethods = new ArrayList<>(); + for (Map.Entry entry : authenticatedIdPs.entrySet()) { + if (entry.getValue() != null && entry.getValue().getAuthenticators() != null) { + for (AuthenticatorConfig authenticatorConfig : entry.getValue().getAuthenticators()) { + if (authenticatorConfig != null && authenticatorConfig.getAmrValues() != null) { + resultantAuthMethods.addAll(Arrays.asList(authenticatorConfig.getAmrValues())); + } + } + } + } + return resultantAuthMethods; + }//implement the logic using for loops + boolean readAMRValueFromIdp = Boolean.parseBoolean(IdentityUtil.getProperty( OAuthConstants.READ_AMR_VALUE_FROM_IDP)); if (readAMRValueFromIdp) { diff --git a/pom.xml b/pom.xml index 78feb19039d..03777bcae9d 100644 --- a/pom.xml +++ b/pom.xml @@ -967,7 +967,7 @@ [1.0.1, 2.0.0) - 7.7.140 + 7.7.167-SNAPSHOT [5.25.234, 8.0.0) [2.0.0, 3.0.0) From 9a04e812bd4efab03ada248a2ab456e7d969f726 Mon Sep 17 00:00:00 2001 From: LE Weerasinghe Date: Thu, 20 Feb 2025 17:59:48 +0530 Subject: [PATCH 2/3] Add-amr conflict resolve --- .../oauth/endpoint/authz/OAuth2AuthzEndpoint.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzEndpoint.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzEndpoint.java index 87582e9a246..d95c3e38ec4 100644 --- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzEndpoint.java +++ b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzEndpoint.java @@ -4206,6 +4206,21 @@ private void associateAuthenticationHistory(SessionDataCacheEntry resultFromLogi */ private List getAMRValues(List authMethods, Map authenticatedIdPs) { + boolean authenticatorAMREnabled = true; + if (authenticatorAMREnabled) { + List resultantAuthMethods = new ArrayList<>(); + for (Map.Entry entry : authenticatedIdPs.entrySet()) { + if (entry.getValue() != null && entry.getValue().getAuthenticators() != null) { + for (AuthenticatorConfig authenticatorConfig : entry.getValue().getAuthenticators()) { + if (authenticatorConfig != null && authenticatorConfig.getAmrValues() != null) { + resultantAuthMethods.addAll(Arrays.asList(authenticatorConfig.getAmrValues())); + } + } + } + } + return resultantAuthMethods; + }//implement the logic using for loops + boolean readAMRValueFromIdp = Boolean.parseBoolean(IdentityUtil.getProperty( OAuthConstants.READ_AMR_VALUE_FROM_IDP)); if (readAMRValueFromIdp) { From 008f9a612b43ca962fedb6668221149dbfed313d Mon Sep 17 00:00:00 2001 From: LE Weerasinghe Date: Tue, 25 Feb 2025 16:49:34 +0530 Subject: [PATCH 3/3] update getAmrValues to getAmrValue --- .../identity/oauth/endpoint/authz/OAuth2AuthzEndpoint.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzEndpoint.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzEndpoint.java index d95c3e38ec4..82026e8d18b 100644 --- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzEndpoint.java +++ b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzEndpoint.java @@ -4212,8 +4212,8 @@ private List getAMRValues(List authMethods, Map entry : authenticatedIdPs.entrySet()) { if (entry.getValue() != null && entry.getValue().getAuthenticators() != null) { for (AuthenticatorConfig authenticatorConfig : entry.getValue().getAuthenticators()) { - if (authenticatorConfig != null && authenticatorConfig.getAmrValues() != null) { - resultantAuthMethods.addAll(Arrays.asList(authenticatorConfig.getAmrValues())); + if (authenticatorConfig != null && authenticatorConfig.getAmrValue() != null) { + resultantAuthMethods.addAll(Arrays.asList(authenticatorConfig.getAmrValue())); } } }