use of com.mercedesbenz.sechub.domain.schedule.access.ScheduleAccess.ProjectAccessCompositeKey in project sechub by mercedes-benz.
the class ScheduleUserAccessToProjectValidationService method assertUserHasAccessToProject.
/**
* Assert user logged in has access to project
*
* @param projectId
*/
public void assertUserHasAccessToProject(String projectId) {
if (userContextService.isSuperAdmin()) {
if (!accessRepository.hasProjectUserAccess(projectId)) {
throw new NotFoundException("Project " + projectId + " does not exist, or no user has access at all.");
}
return;
}
String userId = userContextService.getUserId();
ProjectAccessCompositeKey key = new ProjectAccessCompositeKey(userId, projectId);
Optional<ScheduleAccess> scheduleAccess = accessRepository.findById(key);
if (!scheduleAccess.isPresent()) {
securityLogService.log(SecurityLogType.POTENTIAL_INTRUSION, "Denied user access in domain 'schedule'. 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.schedule.access.ScheduleAccess.ProjectAccessCompositeKey in project sechub by mercedes-benz.
the class SchedulerRestControllerRestDocTest method before.
@Before
public void before() {
randomUUID = UUID.randomUUID();
project1 = mock(ScheduleAccess.class);
ProjectAccessCompositeKey key = new ProjectAccessCompositeKey("user", PROJECT1_ID);
when(project1.getKey()).thenReturn(key);
when(mockedProjectRepository.findById(key)).thenReturn(Optional.of(project1));
when(sechubConfigurationValidator.supports(SecHubConfiguration.class)).thenReturn(true);
}
use of com.mercedesbenz.sechub.domain.schedule.access.ScheduleAccess.ProjectAccessCompositeKey in project sechub by mercedes-benz.
the class SchedulerRestControllerMockTest method before.
@Before
public void before() {
randomUUID = UUID.randomUUID();
project1 = mock(ScheduleAccess.class);
ProjectAccessCompositeKey key = new ProjectAccessCompositeKey("user", PROJECT1_ID);
when(project1.getKey()).thenReturn(key);
when(mockedProjectRepository.findById(key)).thenReturn(Optional.of(project1));
when(sechubConfigurationValidator.supports(SecHubConfiguration.class)).thenReturn(true);
}
use of com.mercedesbenz.sechub.domain.schedule.access.ScheduleAccess.ProjectAccessCompositeKey in project sechub by mercedes-benz.
the class ScheduleAccessCountService method countProjectAccess.
public long countProjectAccess(String projectId) {
assertion.assertIsValidProjectId(projectId);
ScheduleAccess probe = new ScheduleAccess();
probe.key = new ProjectAccessCompositeKey(null, projectId);
Example<ScheduleAccess> example = Example.of(probe);
return repository.count(example);
}
use of com.mercedesbenz.sechub.domain.schedule.access.ScheduleAccess.ProjectAccessCompositeKey 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);
}
Aggregations