use of org.wso2.carbon.identity.role.mgt.core.IdentityRoleManagementException in project carbon-identity-framework by wso2.
the class GroupDAOImpl method getGroupNameByID.
@Override
public String getGroupNameByID(String id, String tenantDomain) throws IdentityRoleManagementException {
int tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
String groupName = null;
try (Connection connection = IdentityDatabaseUtil.getDBConnection(false)) {
try (NamedPreparedStatement statement = new NamedPreparedStatement(connection, GET_GROUP_NAME_BY_ID_SQL)) {
statement.setInt(RoleConstants.RoleTableColumns.TENANT_ID, tenantId);
statement.setString(RoleConstants.RoleTableColumns.ATTR_NAME, RoleConstants.ID_URI);
statement.setString(RoleConstants.RoleTableColumns.ATTR_VALUE, id);
int count = 0;
try (ResultSet resultSet = statement.executeQuery()) {
while (resultSet.next()) {
// Handle multiple matching groups.
count++;
if (count > 1) {
String errorMessage = "Invalid scenario. Multiple groups found for the given group ID: " + id + " and " + "tenantDomain: " + tenantDomain;
throw new IdentityRoleManagementClientException(INVALID_REQUEST.getCode(), errorMessage);
}
groupName = resultSet.getString(1);
}
}
}
} catch (SQLException e) {
String errorMessage = "Error while resolving the group name for the given group ID: " + id + " and tenantDomain: " + tenantDomain;
throw new IdentityRoleManagementServerException(UNEXPECTED_SERVER_ERROR.getCode(), errorMessage, e);
}
return groupName;
}
use of org.wso2.carbon.identity.role.mgt.core.IdentityRoleManagementException in project carbon-identity-framework by wso2.
the class GroupDAOImpl method batchProcessGroupIDs.
private Map<String, String> batchProcessGroupIDs(List<String> ids, String tenantDomain, Connection connection) throws SQLException, IdentityRoleManagementException {
Map<String, String> groupIdsToNames = new HashMap<>();
int tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
String groupName;
for (String id : ids) {
try (NamedPreparedStatement statement = new NamedPreparedStatement(connection, GET_GROUP_NAME_BY_ID_SQL)) {
statement.setInt(RoleConstants.RoleTableColumns.TENANT_ID, tenantId);
statement.setString(RoleConstants.RoleTableColumns.ATTR_NAME, RoleConstants.ID_URI);
statement.setString(RoleConstants.RoleTableColumns.ATTR_VALUE, id);
int count = 0;
try (ResultSet resultSet = statement.executeQuery()) {
while (resultSet.next()) {
// Handle multiple matching groups.
count++;
if (count > 1) {
String errorMessage = "Invalid scenario. Multiple groups found for the given group ID: " + id + " and " + "tenantDomain: " + tenantDomain;
throw new IdentityRoleManagementClientException(INVALID_REQUEST.getCode(), errorMessage);
}
groupName = resultSet.getString(1);
groupIdsToNames.put(id, groupName);
}
}
}
}
return groupIdsToNames;
}
use of org.wso2.carbon.identity.role.mgt.core.IdentityRoleManagementException in project carbon-identity-framework by wso2.
the class RoleManagementServiceImpl method getUserListOfRole.
@Override
public List<UserBasicInfo> getUserListOfRole(String roleID, String tenantDomain) throws IdentityRoleManagementException {
RoleManagementEventPublisherProxy roleManagementEventPublisherProxy = RoleManagementEventPublisherProxy.getInstance();
roleManagementEventPublisherProxy.publishPreGetGroupListOfRole(roleID, tenantDomain);
List<UserBasicInfo> userBasicInfoList = roleDAO.getUserListOfRole(roleID, tenantDomain);
roleManagementEventPublisherProxy.publishPostGetGroupListOfRole(roleID, tenantDomain);
if (log.isDebugEnabled()) {
log.debug(String.format("%s get list of users of role of id : %s successfully.", getUser(tenantDomain), roleID));
}
return userBasicInfoList;
}
use of org.wso2.carbon.identity.role.mgt.core.IdentityRoleManagementException 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.IdentityRoleManagementException 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;
}
Aggregations