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.");
}
}
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);
}
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);
}
Aggregations