use of org.wso2.carbon.identity.role.mgt.core.RoleBasicInfo in project carbon-identity-framework by wso2.
the class RoleManagementServiceImpl method updateUserListOfRole.
@Override
public RoleBasicInfo updateUserListOfRole(String roleID, List<String> newUserIDList, List<String> deletedUserIDList, String tenantDomain) throws IdentityRoleManagementException {
RoleManagementEventPublisherProxy roleManagementEventPublisherProxy = RoleManagementEventPublisherProxy.getInstance();
roleManagementEventPublisherProxy.publishPreUpdateUserListOfRole(roleID, newUserIDList, deletedUserIDList, tenantDomain);
RoleBasicInfo roleBasicInfo = roleDAO.updateUserListOfRole(roleID, newUserIDList, deletedUserIDList, tenantDomain);
roleManagementEventPublisherProxy.publishPostUpdateUserListOfRole(roleID, newUserIDList, deletedUserIDList, tenantDomain);
if (log.isDebugEnabled()) {
log.debug(String.format("%s updated list of users of role of id : %s successfully.", getUser(tenantDomain), roleID));
}
audit.info(String.format(auditMessage, getUser(tenantDomain), "Update users list of role by id", roleID, getAuditData(tenantDomain), success));
return roleBasicInfo;
}
use of org.wso2.carbon.identity.role.mgt.core.RoleBasicInfo in project carbon-identity-framework by wso2.
the class RoleManagementServiceImpl method setPermissionsForRole.
@Override
public RoleBasicInfo setPermissionsForRole(String roleID, List<String> permissions, String tenantDomain) throws IdentityRoleManagementException {
RoleManagementEventPublisherProxy roleManagementEventPublisherProxy = RoleManagementEventPublisherProxy.getInstance();
roleManagementEventPublisherProxy.publishPreSetPermissionsForRole(roleID, permissions, tenantDomain);
RoleBasicInfo roleBasicInfo = roleDAO.setPermissionsForRole(roleID, permissions, tenantDomain);
roleManagementEventPublisherProxy.publishPostSetPermissionsForRole(roleID, permissions, tenantDomain);
if (log.isDebugEnabled()) {
log.debug(String.format("%s set list of permissions of role of id : %s successfully.", getUser(tenantDomain), roleID));
}
audit.info(String.format(auditMessage, getUser(tenantDomain), "Set permission for role by id", roleID, getAuditData(tenantDomain), success));
return roleBasicInfo;
}
use of org.wso2.carbon.identity.role.mgt.core.RoleBasicInfo in project carbon-identity-framework by wso2.
the class RoleDAOImpl method getRoles.
@Override
public List<RoleBasicInfo> getRoles(Integer limit, Integer offset, String sortBy, String sortOrder, String tenantDomain) throws IdentityRoleManagementException {
int tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
limit = validateLimit(limit);
offset = validateOffset(offset);
validateAttributesForSorting(sortBy, sortOrder);
List<RoleBasicInfo> roles;
try (Connection connection = IdentityDatabaseUtil.getUserDBConnection(false)) {
String databaseProductName = connection.getMetaData().getDatabaseProductName();
try (NamedPreparedStatement statement = new NamedPreparedStatement(connection, getDBTypeSpecificRolesRetrievalQuery(databaseProductName), RoleTableColumns.UM_ID)) {
statement.setInt(RoleTableColumns.UM_TENANT_ID, tenantId);
roles = processListRolesQuery(limit, offset, statement, tenantDomain);
}
} catch (SQLException e) {
throw new IdentityRoleManagementServerException(UNEXPECTED_SERVER_ERROR.getCode(), "Error while listing roles in tenantDomain: " + tenantDomain, e);
}
return Collections.unmodifiableList(roles);
}
use of org.wso2.carbon.identity.role.mgt.core.RoleBasicInfo in project carbon-identity-framework by wso2.
the class RoleDAOImpl method setPermissions.
private RoleBasicInfo setPermissions(String roleID, List<String> permissions, String tenantDomain, String roleName) throws IdentityRoleManagementServerException {
roleName = appendInternalDomain(roleName);
/*
Permission list can be empty in case we want to remove the permissions.
Therefore validating for NULL will be sufficient.
*/
if (permissions == null) {
if (log.isDebugEnabled()) {
log.debug("Permissions list is null. Therefore not proceeding further.");
}
return new RoleBasicInfo(roleID, roleName);
}
try {
getUserAdminProxy().setRoleUIPermission(roleName, permissions.toArray(new String[0]));
clearUserRolesCacheByTenant(IdentityTenantUtil.getTenantId(tenantDomain));
return new RoleBasicInfo(roleID, roleName);
} catch (UserAdminException e) {
throw new IdentityRoleManagementServerException(UNEXPECTED_SERVER_ERROR.getCode(), "An error occurred when setting permissions for the role: " + roleName, e);
}
}
use of org.wso2.carbon.identity.role.mgt.core.RoleBasicInfo in project identity-inbound-provisioning-scim2 by wso2-extensions.
the class SCIMRoleManagerTest method testUpdateRoleUpdateRoleName.
@Test(dataProvider = "dataProviderForUpdateRoleUpdateRoleName")
public void testUpdateRoleUpdateRoleName(String roleId, String oldRoleName, String newRoleName, String tenantDomain, String type) throws IdentityRoleManagementException, BadRequestException, CharonException, ConflictException, NotFoundException {
RoleBasicInfo roleBasicInfo = new RoleBasicInfo(roleId, newRoleName);
Role[] oldAndNewRoles = getOldAndNewRoleDummies(roleId, oldRoleName, newRoleName, type);
when(mockRoleManagementService.updateRoleName(anyString(), anyString(), anyString())).thenReturn(roleBasicInfo);
when(mockRoleManagementService.updateUserListOfRole(eq(roleId), anyListOf(String.class), anyListOf(String.class), anyString())).thenReturn(roleBasicInfo);
when(mockRoleManagementService.updateGroupListOfRole(eq(roleId), anyListOf(String.class), anyListOf(String.class), anyString())).thenReturn(roleBasicInfo);
when(mockRoleManagementService.setPermissionsForRole(eq(roleId), anyListOf(String.class), anyString())).thenReturn(roleBasicInfo);
SCIMRoleManager scimRoleManager = new SCIMRoleManager(mockRoleManagementService, tenantDomain);
scimRoleManager.updateRole(oldAndNewRoles[0], oldAndNewRoles[1]);
assertTrue(true, "updateRole execute successfully");
}
Aggregations