Search in sources :

Example 1 with UseCaseAdminUnassignsUserFromProject

use of com.mercedesbenz.sechub.sharedkernel.usecases.admin.user.UseCaseAdminUnassignsUserFromProject in project sechub by mercedes-benz.

the class ProjectUnassignUserService method unassignUserFromProject.

/* @formatter:off */
@UseCaseAdminUnassignsUserFromProject(@Step(number = 2, name = "Unassign user", description = "The service will remove the user to the project. If users has no longer access to projects ROLE_USER will be removed"))
public /* @formatter:on */
void unassignUserFromProject(String userId, String projectId) {
    auditLogService.log("triggers unassignment of user:{} to project:{}", logSanitizer.sanitize(userId, 30), logSanitizer.sanitize(projectId, 30));
    assertion.assertIsValidUserId(userId);
    assertion.assertIsValidProjectId(projectId);
    Project project = projectRepository.findOrFailProject(projectId);
    User user = userRepository.findOrFailUser(userId);
    if (!project.getUsers().remove(user)) {
        throw new AlreadyExistsException("User already not assigned to this project!");
    }
    user.getProjects().remove(project);
    transactionService.saveInOwnTransaction(project, user);
    sendUserRemovedFromProjectEvent(projectId, user);
    sendRequestUserRoleRecalculation(user);
}
Also used : UseCaseAdminUnassignsUserFromProject(com.mercedesbenz.sechub.sharedkernel.usecases.admin.user.UseCaseAdminUnassignsUserFromProject) User(com.mercedesbenz.sechub.domain.administration.user.User) AlreadyExistsException(com.mercedesbenz.sechub.sharedkernel.error.AlreadyExistsException) UseCaseAdminUnassignsUserFromProject(com.mercedesbenz.sechub.sharedkernel.usecases.admin.user.UseCaseAdminUnassignsUserFromProject)

Example 2 with UseCaseAdminUnassignsUserFromProject

use of com.mercedesbenz.sechub.sharedkernel.usecases.admin.user.UseCaseAdminUnassignsUserFromProject in project sechub by mercedes-benz.

the class ScheduleRevokeUserAccessFromProjectService method revokeUserAccessFromProject.

@UseCaseAdminUnassignsUserFromProject(@Step(number = 2, name = "Update authorization parts"))
public void revokeUserAccessFromProject(String userId, String projectId) {
    assertion.assertIsValidUserId(userId);
    assertion.assertIsValidProjectId(projectId);
    ProjectAccessCompositeKey id = new ProjectAccessCompositeKey(userId, projectId);
    repository.deleteById(id);
    LOG.info("Revoked access to project:{} for user:{}", projectId, userId);
}
Also used : ProjectAccessCompositeKey(com.mercedesbenz.sechub.domain.schedule.access.ScheduleAccess.ProjectAccessCompositeKey) UseCaseAdminUnassignsUserFromProject(com.mercedesbenz.sechub.sharedkernel.usecases.admin.user.UseCaseAdminUnassignsUserFromProject)

Example 3 with UseCaseAdminUnassignsUserFromProject

use of com.mercedesbenz.sechub.sharedkernel.usecases.admin.user.UseCaseAdminUnassignsUserFromProject in project sechub by mercedes-benz.

the class ScanRevokeUserAccessFromProjectService method revokeUserAccessFromProject.

@UseCaseAdminUnassignsUserFromProject(@Step(number = 2, name = "Update authorization parts"))
public void revokeUserAccessFromProject(String userId, String projectId) {
    assertion.assertIsValidUserId(userId);
    assertion.assertIsValidProjectId(projectId);
    ProjectAccessCompositeKey id = new ProjectAccessCompositeKey(userId, projectId);
    repository.deleteById(id);
    LOG.info("Revoked access to project:{} for user:{}", projectId, userId);
}
Also used : ProjectAccessCompositeKey(com.mercedesbenz.sechub.domain.scan.access.ScanAccess.ProjectAccessCompositeKey) UseCaseAdminUnassignsUserFromProject(com.mercedesbenz.sechub.sharedkernel.usecases.admin.user.UseCaseAdminUnassignsUserFromProject)

Aggregations

UseCaseAdminUnassignsUserFromProject (com.mercedesbenz.sechub.sharedkernel.usecases.admin.user.UseCaseAdminUnassignsUserFromProject)3 User (com.mercedesbenz.sechub.domain.administration.user.User)1 ProjectAccessCompositeKey (com.mercedesbenz.sechub.domain.scan.access.ScanAccess.ProjectAccessCompositeKey)1 ProjectAccessCompositeKey (com.mercedesbenz.sechub.domain.schedule.access.ScheduleAccess.ProjectAccessCompositeKey)1 AlreadyExistsException (com.mercedesbenz.sechub.sharedkernel.error.AlreadyExistsException)1