Search in sources :

Example 11 with IdentityRoleManagementException

use of org.wso2.carbon.identity.role.mgt.core.IdentityRoleManagementException in project carbon-identity-framework by wso2.

the class RoleDAOImpl method buildRolesList.

private List<RoleBasicInfo> buildRolesList(NamedPreparedStatement statement, String tenantDomain) throws SQLException, IdentityRoleManagementException {
    List<RoleBasicInfo> roles = new ArrayList<>();
    List<String> roleNames = new ArrayList<>();
    try (ResultSet resultSet = statement.executeQuery()) {
        while (resultSet.next()) {
            String roleName = resultSet.getString(1);
            roleNames.add(appendInternalDomain(roleName));
        }
    }
    Map<String, String> roleNamesToIDs = getRoleIDsByNames(roleNames, tenantDomain);
    // Filter scim disabled roles.
    roleNames.removeAll(new ArrayList<>(roleNamesToIDs.keySet()));
    // Add roleIDs for scim disabled roles.
    for (String roleName : roleNames) {
        roleNamesToIDs.put(roleName, addRoleID(roleName, tenantDomain));
    }
    roleNamesToIDs.forEach((roleName, roleID) -> roles.add(new RoleBasicInfo(roleID, removeInternalDomain(roleName))));
    return roles;
}
Also used : ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) RoleBasicInfo(org.wso2.carbon.identity.role.mgt.core.RoleBasicInfo)

Example 12 with IdentityRoleManagementException

use of org.wso2.carbon.identity.role.mgt.core.IdentityRoleManagementException in project carbon-identity-framework by wso2.

the class RoleManagementServiceImpl method deleteRole.

@Override
public void deleteRole(String roleID, String tenantDomain) throws IdentityRoleManagementException {
    RoleManagementEventPublisherProxy roleManagementEventPublisherProxy = RoleManagementEventPublisherProxy.getInstance();
    roleManagementEventPublisherProxy.publishPreDeleteRole(roleID, tenantDomain);
    roleDAO.deleteRole(roleID, tenantDomain);
    roleManagementEventPublisherProxy.publishPostDeleteRole(roleID, tenantDomain);
    if (log.isDebugEnabled()) {
        log.debug(String.format("%s deleted role of id : %s successfully.", getUser(tenantDomain), roleID));
    }
    audit.info(String.format(auditMessage, getUser(tenantDomain), "Delete role by id", roleID, getAuditData(tenantDomain), success));
}
Also used : RoleManagementEventPublisherProxy(org.wso2.carbon.identity.role.mgt.core.RoleManagementEventPublisherProxy)

Example 13 with IdentityRoleManagementException

use of org.wso2.carbon.identity.role.mgt.core.IdentityRoleManagementException in project carbon-identity-framework by wso2.

the class RoleManagementServiceImpl method updateRoleName.

@Override
public RoleBasicInfo updateRoleName(String roleID, String newRoleName, String tenantDomain) throws IdentityRoleManagementException {
    RoleManagementEventPublisherProxy roleManagementEventPublisherProxy = RoleManagementEventPublisherProxy.getInstance();
    roleManagementEventPublisherProxy.publishPreUpdateRoleName(roleID, newRoleName, tenantDomain);
    RoleBasicInfo roleBasicInfo = roleDAO.updateRoleName(roleID, newRoleName, tenantDomain);
    roleManagementEventPublisherProxy.publishPostUpdateRoleName(roleID, newRoleName, tenantDomain);
    if (log.isDebugEnabled()) {
        log.debug(String.format("%s updated role name of role id : %s successfully.", getUser(tenantDomain), roleID));
    }
    audit.info(String.format(auditMessage, getUser(tenantDomain), "Update role name by ID", roleID, getAuditData(tenantDomain, newRoleName), success));
    return roleBasicInfo;
}
Also used : RoleManagementEventPublisherProxy(org.wso2.carbon.identity.role.mgt.core.RoleManagementEventPublisherProxy) RoleBasicInfo(org.wso2.carbon.identity.role.mgt.core.RoleBasicInfo)

Example 14 with IdentityRoleManagementException

use of org.wso2.carbon.identity.role.mgt.core.IdentityRoleManagementException in project carbon-identity-framework by wso2.

the class RoleManagementServiceImpl method getRole.

@Override
public Role getRole(String roleID, String tenantDomain) throws IdentityRoleManagementException {
    RoleManagementEventPublisherProxy roleManagementEventPublisherProxy = RoleManagementEventPublisherProxy.getInstance();
    roleManagementEventPublisherProxy.publishPreGetRole(roleID, tenantDomain);
    Role role = roleDAO.getRole(roleID, tenantDomain);
    roleManagementEventPublisherProxy.publishPostGetRole(roleID, tenantDomain);
    if (log.isDebugEnabled()) {
        log.debug(String.format("%s get role of id : %s successfully.", getUser(tenantDomain), roleID));
    }
    return role;
}
Also used : Role(org.wso2.carbon.identity.role.mgt.core.Role) RoleManagementEventPublisherProxy(org.wso2.carbon.identity.role.mgt.core.RoleManagementEventPublisherProxy)

Example 15 with IdentityRoleManagementException

use of org.wso2.carbon.identity.role.mgt.core.IdentityRoleManagementException in project carbon-identity-framework by wso2.

the class RoleManagementServiceImpl method updateGroupListOfRole.

@Override
public RoleBasicInfo updateGroupListOfRole(String roleID, List<String> newGroupIDList, List<String> deletedGroupIDList, String tenantDomain) throws IdentityRoleManagementException {
    RoleManagementEventPublisherProxy roleManagementEventPublisherProxy = RoleManagementEventPublisherProxy.getInstance();
    roleManagementEventPublisherProxy.publishPreUpdateGroupListOfRole(roleID, newGroupIDList, deletedGroupIDList, tenantDomain);
    RoleBasicInfo roleBasicInfo = roleDAO.updateGroupListOfRole(roleID, newGroupIDList, deletedGroupIDList, tenantDomain);
    roleManagementEventPublisherProxy.publishPostUpdateGroupListOfRole(roleID, newGroupIDList, deletedGroupIDList, tenantDomain);
    if (log.isDebugEnabled()) {
        log.debug(String.format("%s updated list of groups of role of id : %s successfully.", getUser(tenantDomain), roleID));
    }
    audit.info(String.format(auditMessage, getUser(tenantDomain), "Update group list of role by id", roleID, getAuditData(tenantDomain), success));
    return roleBasicInfo;
}
Also used : RoleManagementEventPublisherProxy(org.wso2.carbon.identity.role.mgt.core.RoleManagementEventPublisherProxy) RoleBasicInfo(org.wso2.carbon.identity.role.mgt.core.RoleBasicInfo)

Aggregations

IdentityRoleManagementClientException (org.wso2.carbon.identity.role.mgt.core.IdentityRoleManagementClientException)29 IdentityRoleManagementServerException (org.wso2.carbon.identity.role.mgt.core.IdentityRoleManagementServerException)23 RoleBasicInfo (org.wso2.carbon.identity.role.mgt.core.RoleBasicInfo)22 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)20 Test (org.testng.annotations.Test)20 NamedPreparedStatement (org.wso2.carbon.database.utils.jdbc.NamedPreparedStatement)20 Connection (java.sql.Connection)19 SQLException (java.sql.SQLException)19 Matchers.anyString (org.mockito.Matchers.anyString)14 IdentityRoleManagementException (org.wso2.carbon.identity.role.mgt.core.IdentityRoleManagementException)14 Role (org.wso2.charon3.core.objects.Role)13 ResultSet (java.sql.ResultSet)12 RoleManagementEventPublisherProxy (org.wso2.carbon.identity.role.mgt.core.RoleManagementEventPublisherProxy)11 ArrayList (java.util.ArrayList)9 CharonException (org.wso2.charon3.core.exceptions.CharonException)8 ExpressionNode (org.wso2.charon3.core.utils.codeutils.ExpressionNode)8 Node (org.wso2.charon3.core.utils.codeutils.Node)8 OperationNode (org.wso2.charon3.core.utils.codeutils.OperationNode)8 UserStoreException (org.wso2.carbon.user.api.UserStoreException)6 BadRequestException (org.wso2.charon3.core.exceptions.BadRequestException)6