Search in sources :

Example 1 with ProjectAccessCompositeKey

use of com.mercedesbenz.sechub.domain.scan.access.ScanAccess.ProjectAccessCompositeKey in project sechub by mercedes-benz.

the class ScanUserAccessToProjectValidationService method assertUserHasAccessToProject.

/**
 * Assert user logged in has access to project
 *
 * @param projectId
 */
public void assertUserHasAccessToProject(String projectId) {
    if (userContextService.isSuperAdmin()) {
        /* a super admin has always access */
        return;
    }
    String userId = userContextService.getUserId();
    ProjectAccessCompositeKey key = new ProjectAccessCompositeKey(userId, projectId);
    Optional<ScanAccess> project = accessRepository.findById(key);
    if (!project.isPresent()) {
        securityLogService.log(SecurityLogType.POTENTIAL_INTRUSION, "Denied user access in domain 'scan'. userId={},projectId={}", userId, logSanitizer.sanitize(projectId, 30));
        // bad guys they got a target...
        throw new NotFoundException("Project " + projectId + " does not exist, or you have no access.");
    }
}
Also used : NotFoundException(com.mercedesbenz.sechub.sharedkernel.error.NotFoundException) ProjectAccessCompositeKey(com.mercedesbenz.sechub.domain.scan.access.ScanAccess.ProjectAccessCompositeKey)

Example 2 with ProjectAccessCompositeKey

use of com.mercedesbenz.sechub.domain.scan.access.ScanAccess.ProjectAccessCompositeKey in project sechub by mercedes-benz.

the class ScanAccessCountService method countProjectAccess.

public long countProjectAccess(String projectId) {
    assertion.assertIsValidProjectId(projectId);
    ScanAccess probe = new ScanAccess();
    probe.key = new ProjectAccessCompositeKey(null, projectId);
    Example<ScanAccess> example = Example.of(probe);
    return repository.count(example);
}
Also used : ProjectAccessCompositeKey(com.mercedesbenz.sechub.domain.scan.access.ScanAccess.ProjectAccessCompositeKey)

Example 3 with ProjectAccessCompositeKey

use of com.mercedesbenz.sechub.domain.scan.access.ScanAccess.ProjectAccessCompositeKey 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

ProjectAccessCompositeKey (com.mercedesbenz.sechub.domain.scan.access.ScanAccess.ProjectAccessCompositeKey)3 NotFoundException (com.mercedesbenz.sechub.sharedkernel.error.NotFoundException)1 UseCaseAdminUnassignsUserFromProject (com.mercedesbenz.sechub.sharedkernel.usecases.admin.user.UseCaseAdminUnassignsUserFromProject)1