Skip to content

Commit

Permalink
Merge pull request #500 from SujanSanjula96/fix-system-role-2
Browse files Browse the repository at this point in the history
Fix error while retrieving system role in super tenant
  • Loading branch information
AnuradhaSK authored Oct 29, 2023
2 parents 5f14ee6 + 34bf525 commit 5492d59
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
6 changes: 6 additions & 0 deletions components/org.wso2.carbon.identity.scim2.common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@
<groupId>org.wso2.carbon.identity.organization.management.core</groupId>
<artifactId>org.wso2.carbon.identity.organization.management.service</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.event.handler.accountlock</groupId>
<artifactId>org.wso2.carbon.identity.handler.event.account.lock</artifactId>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
Expand Down Expand Up @@ -238,6 +242,8 @@
version="${carbon.identity.framework.imp.pkg.version.range}",
org.wso2.carbon.identity.organization.management.service.*;
version="${org.wso2.carbon.identity.organization.management.core.version.range}",
org.wso2.carbon.identity.handler.event.account.lock.*;
version="${carbon.identity.account.lock.handler.imp.pkg.version.range}",
</Import-Package>
<Export-Package>
!org.wso2.carbon.identity.scim2.common.internal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ protected void activate(ComponentContext ctx) {
AdminAttributeUtil.updateAdminUser(MultitenantConstants.SUPER_TENANT_ID, true);
AdminAttributeUtil.updateAdminGroup(MultitenantConstants.SUPER_TENANT_ID);
SCIMCommonUtils.updateEveryOneRoleV2MetaData(MultitenantConstants.SUPER_TENANT_ID);
SCIMCommonUtils.updateSystemRoleV2MetaData(MultitenantConstants.SUPER_TENANT_ID);
if (logger.isDebugEnabled()) {
logger.debug("SCIM Common component activated successfully.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.wso2.carbon.identity.core.URLBuilderException;
import org.wso2.carbon.identity.core.util.IdentityTenantUtil;
import org.wso2.carbon.identity.core.util.IdentityUtil;
import org.wso2.carbon.identity.handler.event.account.lock.constants.AccountConstants;
import org.wso2.carbon.identity.scim2.common.cache.SCIMCustomAttributeSchemaCache;
import org.wso2.carbon.identity.scim2.common.exceptions.IdentitySCIMException;
import org.wso2.carbon.identity.scim2.common.group.SCIMGroupHandler;
Expand Down Expand Up @@ -859,12 +860,29 @@ public static void updateEveryOneRoleV2MetaData(int tenantId) {
try {
UserStoreManager userStoreManager = (UserStoreManager) SCIMCommonComponentHolder.getRealmService().
getTenantUserRealm(tenantId).getUserStoreManager();
String domainName = UserCoreUtil.getDomainName(userStoreManager.getRealmConfiguration());
SCIMGroupHandler scimGroupHandler = new SCIMGroupHandler(userStoreManager.getTenantId());
String everyoneRoleName = userStoreManager.getRealmConfiguration().getEveryOneRoleName();
String everyoneRoleNameWithDomain =
UserCoreUtil.addDomainToName(everyoneRoleName, domainName);
scimGroupHandler.addRoleV2MandatoryAttributes(everyoneRoleNameWithDomain);
scimGroupHandler.addRoleV2MandatoryAttributes(everyoneRoleName);
} catch (org.wso2.carbon.user.api.UserStoreException | IdentitySCIMException e) {
log.error(e);
}
}
}

/**
* Update system role meta data.
*
* @param tenantId Tenant Id.
*/
public static void updateSystemRoleV2MetaData(int tenantId) {

// Handle system role creation also here if legacy runtime is disabled.
if (!CarbonConstants.ENABLE_LEGACY_AUTHZ_RUNTIME) {
try {
UserStoreManager userStoreManager = (UserStoreManager) SCIMCommonComponentHolder.getRealmService().
getTenantUserRealm(tenantId).getUserStoreManager();
SCIMGroupHandler scimGroupHandler = new SCIMGroupHandler(userStoreManager.getTenantId());
scimGroupHandler.addRoleV2MandatoryAttributes(AccountConstants.ACCOUNT_LOCK_BYPASS_ROLE);
} catch (org.wso2.carbon.user.api.UserStoreException | IdentitySCIMException e) {
log.error(e);
}
Expand Down
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@
<artifactId>org.wso2.carbon.identity.organization.management.service</artifactId>
<version>${org.wso2.carbon.identity.organization.management.core.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.event.handler.accountlock</groupId>
<artifactId>org.wso2.carbon.identity.handler.event.account.lock</artifactId>
<version>${org.wso2.carbon.identity.handler.event.account.lock.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.inbound.provisioning.scim2</groupId>
<artifactId>org.wso2.carbon.identity.scim2.common</artifactId>
Expand Down Expand Up @@ -280,6 +286,8 @@
<charon.version>4.0.14</charon.version>
<org.wso2.carbon.identity.organization.management.core.version>1.0.76
</org.wso2.carbon.identity.organization.management.core.version>
<org.wso2.carbon.identity.handler.event.account.lock.version>1.8.13
</org.wso2.carbon.identity.handler.event.account.lock.version>

<!--Maven Plugin Version-->
<maven.compiler.plugin.version>2.3.1</maven.compiler.plugin.version>
Expand Down Expand Up @@ -310,6 +318,8 @@
</carbon.identity.framework.imp.pkg.version.range>
<org.wso2.carbon.identity.organization.management.core.version.range>[1.0.0, 2.0.0)
</org.wso2.carbon.identity.organization.management.core.version.range>
<carbon.identity.account.lock.handler.imp.pkg.version.range>[1.1.12, 2.0.0)
</carbon.identity.account.lock.handler.imp.pkg.version.range>

<org.slf4j.verison>1.7.21</org.slf4j.verison>
<testng.version>6.9.10</testng.version>
Expand Down

0 comments on commit 5492d59

Please sign in to comment.