Skip to content

Commit

Permalink
Fix shared role update issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ChanikaRuchini committed Oct 27, 2023
1 parent ab584c2 commit 9644c77
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1190,11 +1190,12 @@ private void updateSharedSCIMRolesName(List<RoleDTO> sharedRoles, String newRole
throws IdentityRoleManagementException {

for (RoleDTO roleDTO : sharedRoles) {
String roleName = appendInternalDomain(roleDTO.getName());
try (NamedPreparedStatement statement = new NamedPreparedStatement(connection, UPDATE_SCIM_ROLE_NAME_SQL,
RoleConstants.RoleTableColumns.ID)) {
statement.setString(RoleConstants.RoleTableColumns.NEW_ROLE_NAME, newRoleName);
statement.setInt(RoleConstants.RoleTableColumns.TENANT_ID, roleDTO.getTenantId());
statement.setString(ROLE_NAME, roleDTO.getName());
statement.setString(ROLE_NAME, roleName);
statement.setInt(RoleConstants.RoleTableColumns.AUDIENCE_REF_ID, roleDTO.getAudienceRefId());
statement.executeUpdate();
} catch (SQLException e) {
Expand Down Expand Up @@ -2940,7 +2941,6 @@ private void deleteSCIMRole(String roleId, String roleName, int audienceRefId, L

int tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
// Append internal domain in order to maintain the backward compatibility.
roleName = appendInternalDomain(roleName);
if (log.isDebugEnabled()) {
log.debug("Deleting the role id: " + roleId + " in the tenantDomain: "
+ tenantDomain);
Expand Down Expand Up @@ -3016,7 +3016,8 @@ private List<RoleDTO> getSharedHybridRoles(String roleId, int mainTenantId,
String name = resultSet.getString(1);
int tenantId = resultSet.getInt(2);
int audienceRefId = resultSet.getInt(3);
hybridRoles.add(new RoleDTO(name, audienceRefId, tenantId));
String id = resultSet.getString(4);
hybridRoles.add(new RoleDTO(name, id, audienceRefId, tenantId));
}
}
} catch (SQLException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public class SQLQueries {
"WHERE ROLE_NAME =:ROLE_NAME; AND TENANT_ID =:TENANT_ID; AND AUDIENCE_REF_ID =:AUDIENCE_REF_ID;";

public static final String GET_SHARED_ROLES_SQL = "SELECT UM_HYBRID_ROLE.UM_ROLE_NAME, " +
"UM_HYBRID_ROLE.UM_TENANT_ID, UM_HYBRID_ROLE.UM_AUDIENCE_REF_ID FROM UM_SHARED_ROLE JOIN " +
"UM_HYBRID_ROLE ON UM_SHARED_ROLE.UM_SHARED_ROLE_ID = UM_HYBRID_ROLE.UM_ID AND " +
"UM_HYBRID_ROLE.UM_TENANT_ID, UM_HYBRID_ROLE.UM_AUDIENCE_REF_ID, UM_HYBRID_ROLE.UM_UUID FROM " +
"UM_SHARED_ROLE JOIN UM_HYBRID_ROLE ON UM_SHARED_ROLE.UM_SHARED_ROLE_ID = UM_HYBRID_ROLE.UM_ID AND " +
"UM_SHARED_ROLE.UM_SHARED_ROLE_TENANT_ID = UM_HYBRID_ROLE.UM_TENANT_ID WHERE " +
"UM_SHARED_ROLE.UM_MAIN_ROLE_ID IN (SELECT UM_ID FROM UM_HYBRID_ROLE WHERE UM_UUID=:UM_UUID; AND " +
"UM_TENANT_ID =:UM_TENANT_ID;);";
Expand Down

0 comments on commit 9644c77

Please sign in to comment.