use of org.wso2.carbon.identity.role.mgt.core.IdentityRoleManagementException in project carbon-identity-framework by wso2.
the class RoleManagementServiceImpl method getPermissionListOfRole.
@Override
public List<String> getPermissionListOfRole(String roleID, String tenantDomain) throws IdentityRoleManagementException {
RoleManagementEventPublisherProxy roleManagementEventPublisherProxy = RoleManagementEventPublisherProxy.getInstance();
roleManagementEventPublisherProxy.publishPreGetPermissionListOfRole(roleID, tenantDomain);
List<String> permissionListOfRole = roleDAO.getPermissionListOfRole(roleID, tenantDomain);
roleManagementEventPublisherProxy.publishPostGetPermissionListOfRole(roleID, tenantDomain);
if (log.isDebugEnabled()) {
log.debug(String.format("%s get list of permissions of role of id : %s successfully.", getUser(tenantDomain), roleID));
}
return permissionListOfRole;
}
use of org.wso2.carbon.identity.role.mgt.core.IdentityRoleManagementException in project carbon-identity-framework by wso2.
the class GroupIDResolver method getNameByID.
@Override
public String getNameByID(String id, String tenantDomain) throws IdentityRoleManagementException {
GroupDAO groupDAO = RoleMgtDAOFactory.getInstance().getGroupDAO();
String groupName = groupDAO.getGroupNameByID(id, tenantDomain);
if (groupName == null) {
String errorMessage = "A group doesn't exist with id: " + id + " in the tenantDomain: " + tenantDomain;
throw new IdentityRoleManagementClientException(INVALID_REQUEST.getCode(), errorMessage);
}
return groupName;
}
use of org.wso2.carbon.identity.role.mgt.core.IdentityRoleManagementException in project carbon-identity-framework by wso2.
the class GroupIDResolver method getIDByName.
@Override
public String getIDByName(String name, String tenantDomain) throws IdentityRoleManagementException {
GroupDAO groupDAO = RoleMgtDAOFactory.getInstance().getGroupDAO();
String groupName = groupDAO.getGroupIDByName(name, tenantDomain);
if (groupName == null) {
String errorMessage = "A group doesn't exist with name: " + name + " in the tenantDomain: " + tenantDomain;
throw new IdentityRoleManagementClientException(INVALID_REQUEST.getCode(), errorMessage);
}
return groupName;
}
use of org.wso2.carbon.identity.role.mgt.core.IdentityRoleManagementException 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.IdentityRoleManagementException in project carbon-identity-framework by wso2.
the class RoleDAOImpl method deleteUser.
@Override
public void deleteUser(String userID, String tenantDomain) throws IdentityRoleManagementException {
String userName = getUserNameByID(userID, tenantDomain);
int tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
String primaryDomainName = IdentityUtil.getPrimaryDomainName();
if (primaryDomainName != null) {
primaryDomainName = primaryDomainName.toUpperCase(Locale.ENGLISH);
}
try (Connection connection = IdentityDatabaseUtil.getUserDBConnection(true)) {
try (NamedPreparedStatement statement = new NamedPreparedStatement(connection, DELETE_USER_SQL, RoleTableColumns.UM_ID)) {
// Add domain if not set.
userName = UserCoreUtil.addDomainToName(userName, primaryDomainName);
// Get domain from name.
String domainName = UserCoreUtil.extractDomainFromName(userName);
if (domainName != null) {
domainName = domainName.toUpperCase(Locale.ENGLISH);
}
String nameWithoutDomain = UserCoreUtil.removeDomainFromName(userName);
statement.setString(RoleTableColumns.UM_USER_NAME, nameWithoutDomain);
statement.setInt(RoleTableColumns.UM_TENANT_ID, tenantId);
statement.setString(RoleTableColumns.UM_DOMAIN_NAME, domainName);
statement.executeUpdate();
IdentityDatabaseUtil.commitUserDBTransaction(connection);
} catch (SQLException e) {
IdentityDatabaseUtil.rollbackUserDBTransaction(connection);
String errorMessage = "Error while removing the user: %s in the tenantDomain: %s";
throw new IdentityRoleManagementServerException(UNEXPECTED_SERVER_ERROR.getCode(), String.format(errorMessage, userName, tenantDomain), e);
}
} catch (SQLException e) {
String errorMessage = "Error while removing the user: %s in the tenantDomain: %s";
throw new IdentityRoleManagementServerException(UNEXPECTED_SERVER_ERROR.getCode(), String.format(errorMessage, userName, tenantDomain), e);
}
clearUserRolesCache(userName, tenantId);
}
Aggregations