use of com.mercedesbenz.sechub.sharedkernel.project.ProjectAccessLevel in project sechub by mercedes-benz.
the class ScanMessageHandler method handleProcessAccessLevelChanged.
@IsReceivingAsyncMessage(MessageID.PROJECT_ACCESS_LEVEL_CHANGED)
@UseCaseAdministratorChangesProjectAccessLevel(@Step(number = 3, name = "Event handler", description = "Receives change project access level event"))
private void handleProcessAccessLevelChanged(DomainMessage request) {
ProjectMessage data = request.get(MessageDataKeys.PROJECT_ACCESS_LEVEL_CHANGE_DATA);
String projectId = data.getProjectId();
ProjectAccessLevel formerAccessLevel = data.getFormerAccessLevel();
ProjectAccessLevel newAccessLevel = data.getNewAccessLevel();
projectAccessLevelService.changeProjectAccessLevel(projectId, newAccessLevel, formerAccessLevel);
}
use of com.mercedesbenz.sechub.sharedkernel.project.ProjectAccessLevel in project sechub by mercedes-benz.
the class ScanProjectConfigAccessLevelService method getProjectAccessLevelOrFallback.
private ProjectAccessLevel getProjectAccessLevelOrFallback(String projectId, ProjectAccessLevel fallback) {
ProjectAccessLevel defaultValue = fallback;
if (defaultValue == null) {
defaultValue = DEFAULT_ACCESS_LEVEL;
LOG.warn("Given project access level fallback was null - should not happen. Used instead now default :{}", defaultValue.getId());
}
ScanProjectConfig config = scanProjectConfigService.getOrCreate(projectId, CONFIG_ID_PROJECT_ACCESS_LEVEL, false, defaultValue.getId());
ProjectAccessLevel configuredAccessLevel = ProjectAccessLevel.fromId(config.getData());
return configuredAccessLevel;
}
use of com.mercedesbenz.sechub.sharedkernel.project.ProjectAccessLevel in project sechub by mercedes-benz.
the class SchedulerProjectConfigService method changeProjectAccessLevel.
/**
* Change the project access level for given project
*
* @param projectId
* @param newAccessLevel
* @param expectedFormerAccessLevel
*/
public void changeProjectAccessLevel(String projectId, ProjectAccessLevel newAccessLevel, ProjectAccessLevel expectedFormerAccessLevel) {
/* validate */
notNull(newAccessLevel, "new project access level may not be null!");
assertService.assertProjectIdValid(projectId);
/* change config */
SchedulerProjectConfig config = getOrCreateConfig(projectId);
ProjectAccessLevel configuredAccessLevel = config.getProjectAccessLevel();
if (!Objects.equals(configuredAccessLevel, expectedFormerAccessLevel)) {
LOG.warn("Project {} has configured access level: {} but expected former access level was:{}", projectId, configuredAccessLevel, expectedFormerAccessLevel);
}
config.setProjectAccessLevel(newAccessLevel);
repository.save(config);
}
use of com.mercedesbenz.sechub.sharedkernel.project.ProjectAccessLevel in project sechub by mercedes-benz.
the class SchedulerProjectConfigService method isWriteAllowed.
/**
* Checks if project can be written by normal user operations
*
* @param projectId
* @return <code>true</code> when write is possible, otherwise
* <code>false</code>
*/
public boolean isWriteAllowed(String projectId) {
assertService.assertProjectIdValid(projectId);
ProjectAccessLevel accessLevel = getProjectAccessLevelOrFallback(projectId);
return accessLevel.isEqualOrHigherThan(ProjectAccessLevel.FULL);
}
use of com.mercedesbenz.sechub.sharedkernel.project.ProjectAccessLevel in project sechub by mercedes-benz.
the class SchedulerProjectConfigService method isReadAllowed.
/**
* Checks if project can be read by normal user operations
*
* @param projectId
* @return <code>true</code> when read is possible, otherwise <code>false</code>
*/
public boolean isReadAllowed(String projectId) {
assertService.assertProjectIdValid(projectId);
ProjectAccessLevel accessLevel = getProjectAccessLevelOrFallback(projectId);
return accessLevel.isEqualOrHigherThan(ProjectAccessLevel.READ_ONLY);
}
Aggregations