Search in sources :

Example 6 with RoleManagementEventPublisherProxy

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

the class RoleManagementServiceImpl method addRole.

@Override
public RoleBasicInfo addRole(String roleName, List<String> userList, List<String> groupList, List<String> permissions, String tenantDomain) throws IdentityRoleManagementException {
    /* Block the role names with the prefix 'system_' as it is used for the special roles created by the system in
        order to maintain the backward compatibility. */
    if (StringUtils.startsWithIgnoreCase(roleName, UserCoreConstants.INTERNAL_SYSTEM_ROLE_PREFIX)) {
        String errorMessage = String.format("Invalid role name: %s. Role names with the prefix: %s, is not allowed" + " to be created from externally in the system.", roleName, UserCoreConstants.INTERNAL_SYSTEM_ROLE_PREFIX);
        throw new IdentityRoleManagementClientException(INVALID_REQUEST.getCode(), errorMessage);
    }
    RoleManagementEventPublisherProxy roleManagementEventPublisherProxy = RoleManagementEventPublisherProxy.getInstance();
    roleManagementEventPublisherProxy.publishPreAddRole(roleName, userList, groupList, permissions, tenantDomain);
    RoleBasicInfo roleBasicInfo = roleDAO.addRole(roleName, userList, groupList, permissions, tenantDomain);
    roleManagementEventPublisherProxy.publishPostAddRole(roleName, userList, groupList, permissions, tenantDomain);
    if (log.isDebugEnabled()) {
        log.debug(String.format("%s add role of name : %s successfully.", getUser(tenantDomain), roleName));
    }
    audit.info(String.format(auditMessage, getUser(tenantDomain), "Add Role", roleName, getAuditData(tenantDomain), success));
    return roleBasicInfo;
}
Also used : RoleManagementEventPublisherProxy(org.wso2.carbon.identity.role.mgt.core.RoleManagementEventPublisherProxy) IdentityRoleManagementClientException(org.wso2.carbon.identity.role.mgt.core.IdentityRoleManagementClientException) RoleBasicInfo(org.wso2.carbon.identity.role.mgt.core.RoleBasicInfo)

Example 7 with RoleManagementEventPublisherProxy

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

the class RoleManagementServiceImpl method getRoles.

@Override
public List<RoleBasicInfo> getRoles(String filter, Integer limit, Integer offset, String sortBy, String sortOrder, String tenantDomain) throws IdentityRoleManagementException {
    RoleManagementEventPublisherProxy roleManagementEventPublisherProxy = RoleManagementEventPublisherProxy.getInstance();
    roleManagementEventPublisherProxy.publishPreGetRoles(filter, limit, offset, sortBy, sortOrder, tenantDomain);
    List<RoleBasicInfo> roleBasicInfoList = roleDAO.getRoles(filter, limit, offset, sortBy, sortOrder, tenantDomain);
    roleManagementEventPublisherProxy.publishPostGetRoles(filter, limit, offset, sortBy, sortOrder, tenantDomain);
    if (log.isDebugEnabled()) {
        log.debug(String.format("%s get filtered roles successfully.", getUser(tenantDomain)));
    }
    return roleBasicInfoList;
}
Also used : RoleManagementEventPublisherProxy(org.wso2.carbon.identity.role.mgt.core.RoleManagementEventPublisherProxy) RoleBasicInfo(org.wso2.carbon.identity.role.mgt.core.RoleBasicInfo)

Example 8 with RoleManagementEventPublisherProxy

use of org.wso2.carbon.identity.role.mgt.core.RoleManagementEventPublisherProxy 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;
}
Also used : UserBasicInfo(org.wso2.carbon.identity.role.mgt.core.UserBasicInfo) RoleManagementEventPublisherProxy(org.wso2.carbon.identity.role.mgt.core.RoleManagementEventPublisherProxy)

Example 9 with RoleManagementEventPublisherProxy

use of org.wso2.carbon.identity.role.mgt.core.RoleManagementEventPublisherProxy 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;
}
Also used : RoleManagementEventPublisherProxy(org.wso2.carbon.identity.role.mgt.core.RoleManagementEventPublisherProxy) RoleBasicInfo(org.wso2.carbon.identity.role.mgt.core.RoleBasicInfo)

Example 10 with RoleManagementEventPublisherProxy

use of org.wso2.carbon.identity.role.mgt.core.RoleManagementEventPublisherProxy 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;
}
Also used : RoleManagementEventPublisherProxy(org.wso2.carbon.identity.role.mgt.core.RoleManagementEventPublisherProxy) RoleBasicInfo(org.wso2.carbon.identity.role.mgt.core.RoleBasicInfo)

Aggregations

RoleManagementEventPublisherProxy (org.wso2.carbon.identity.role.mgt.core.RoleManagementEventPublisherProxy)11 RoleBasicInfo (org.wso2.carbon.identity.role.mgt.core.RoleBasicInfo)6 GroupBasicInfo (org.wso2.carbon.identity.role.mgt.core.GroupBasicInfo)1 IdentityRoleManagementClientException (org.wso2.carbon.identity.role.mgt.core.IdentityRoleManagementClientException)1 Role (org.wso2.carbon.identity.role.mgt.core.Role)1 UserBasicInfo (org.wso2.carbon.identity.role.mgt.core.UserBasicInfo)1