From ba45081ebba39e676b8496d2fe37dbe9b28508df Mon Sep 17 00:00:00 2001 From: shanggeeth Date: Wed, 11 Dec 2024 10:13:53 +0530 Subject: [PATCH] Change config name to ShowLegacyRoleClaim and address review comments --- .../mgt/ClaimMetadataManagementServiceImpl.java | 2 +- .../metadata/mgt/DefaultClaimMetadataStore.java | 3 +-- .../carbon/identity/core/util/IdentityUtil.java | 13 +++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/components/claim-mgt/org.wso2.carbon.identity.claim.metadata.mgt/src/main/java/org/wso2/carbon/identity/claim/metadata/mgt/ClaimMetadataManagementServiceImpl.java b/components/claim-mgt/org.wso2.carbon.identity.claim.metadata.mgt/src/main/java/org/wso2/carbon/identity/claim/metadata/mgt/ClaimMetadataManagementServiceImpl.java index 46ab3fabd9bb..9692e87b7241 100644 --- a/components/claim-mgt/org.wso2.carbon.identity.claim.metadata.mgt/src/main/java/org/wso2/carbon/identity/claim/metadata/mgt/ClaimMetadataManagementServiceImpl.java +++ b/components/claim-mgt/org.wso2.carbon.identity.claim.metadata.mgt/src/main/java/org/wso2/carbon/identity/claim/metadata/mgt/ClaimMetadataManagementServiceImpl.java @@ -191,7 +191,7 @@ public List getLocalClaims(String tenantDomain) throws ClaimMetadata // Add listener boolean isGroupRoleSeparationEnabled = IdentityUtil.isGroupsVsRolesSeparationImprovementsEnabled(); - boolean isShowRoleClaimOnGroupRoleSeparation = IdentityUtil.isShowRoleClaimOnGroupRoleSeparationEnabled(); + boolean isShowRoleClaimOnGroupRoleSeparation = IdentityUtil.isShowLegacyRoleClaimOnGroupRoleSeparationEnabled(); List filteredLocalClaims = new ArrayList<>(localClaims.size()); for (LocalClaim claim : localClaims) { diff --git a/components/claim-mgt/org.wso2.carbon.identity.claim.metadata.mgt/src/main/java/org/wso2/carbon/identity/claim/metadata/mgt/DefaultClaimMetadataStore.java b/components/claim-mgt/org.wso2.carbon.identity.claim.metadata.mgt/src/main/java/org/wso2/carbon/identity/claim/metadata/mgt/DefaultClaimMetadataStore.java index 13f976305614..bc7b68b7632d 100644 --- a/components/claim-mgt/org.wso2.carbon.identity.claim.metadata.mgt/src/main/java/org/wso2/carbon/identity/claim/metadata/mgt/DefaultClaimMetadataStore.java +++ b/components/claim-mgt/org.wso2.carbon.identity.claim.metadata.mgt/src/main/java/org/wso2/carbon/identity/claim/metadata/mgt/DefaultClaimMetadataStore.java @@ -21,7 +21,6 @@ import org.apache.commons.logging.LogFactory; import org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataException; import org.wso2.carbon.identity.claim.metadata.mgt.internal.IdentityClaimManagementServiceDataHolder; -import org.wso2.carbon.identity.claim.metadata.mgt.internal.ReadOnlyClaimMetadataManager; import org.wso2.carbon.identity.claim.metadata.mgt.internal.ReadWriteClaimMetadataManager; import org.wso2.carbon.identity.claim.metadata.mgt.model.ClaimDialect; import org.wso2.carbon.identity.claim.metadata.mgt.model.ExternalClaim; @@ -459,7 +458,7 @@ private boolean isFilterableClaim(LocalClaim localClaim) { // considered as a legacy claim going forward, thus `roles` and `groups` claims should be used // instead. if (IdentityUtil.isGroupsVsRolesSeparationImprovementsEnabled() && - !IdentityUtil.isShowRoleClaimOnGroupRoleSeparationEnabled() && UserCoreConstants.ROLE_CLAIM. + !IdentityUtil.isShowLegacyRoleClaimOnGroupRoleSeparationEnabled() && UserCoreConstants.ROLE_CLAIM. equals(localClaim.getClaimURI())) { if (log.isDebugEnabled()) { log.debug("Skipping the legacy role claim: " + localClaim.getClaimURI() + ", when getting " + diff --git a/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/util/IdentityUtil.java b/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/util/IdentityUtil.java index 187d2bef7028..78a7980397f5 100644 --- a/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/util/IdentityUtil.java +++ b/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/util/IdentityUtil.java @@ -157,7 +157,7 @@ protected Map initialValue() { private static final String APPLICATION_DOMAIN = "Application"; private static final String WORKFLOW_DOMAIN = "Workflow"; private static Boolean groupsVsRolesSeparationImprovementsEnabled; - private static Boolean showRoleClaimOnGroupRoleSeparationEnabled; + private static Boolean showLegacyRoleClaimOnGroupRoleSeparationEnabled; private static String JAVAX_TRANSFORMER_PROP_VAL = "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl"; // System Property for trust managers. @@ -1634,19 +1634,20 @@ public static boolean isGroupsVsRolesSeparationImprovementsEnabled() { * * @return Where show role claim on group role separation enabled or not. */ - public static boolean isShowRoleClaimOnGroupRoleSeparationEnabled() { + public static boolean isShowLegacyRoleClaimOnGroupRoleSeparationEnabled() { try { UserRealm userRealm = AdminServicesUtil.getUserRealm(); - if(userRealm == null) { + if (userRealm == null) { log.warn("Unable to find the user realm, thus ShowRoleClaimOnGroupRoleSeparationEnabled is set as FALSE."); return Boolean.FALSE; } - if (showRoleClaimOnGroupRoleSeparationEnabled == null) { - showRoleClaimOnGroupRoleSeparationEnabled = UserCoreUtil.isShowRoleClaimOnGroupRoleSeparationEnabled( + if (showLegacyRoleClaimOnGroupRoleSeparationEnabled == null) { + showLegacyRoleClaimOnGroupRoleSeparationEnabled = + UserCoreUtil.isShowLegacyRoleClaimOnGroupRoleSeparationEnabled( userRealm.getRealmConfiguration()); } - return showRoleClaimOnGroupRoleSeparationEnabled; + return showLegacyRoleClaimOnGroupRoleSeparationEnabled; } catch (UserStoreException | CarbonException e) { log.warn("Property value parsing error: ShowRoleClaimOnGroupRoleSeparationEnabled, thus considered as FALSE"); return Boolean.FALSE;