use of net.nemerosa.ontrack.model.settings.SecuritySettings in project ontrack by nemerosa.
the class StructureServiceImpl method getProjectList.
@Override
public List<Project> getProjectList() {
SecuritySettings securitySettings = securityService.getSecuritySettings();
List<Project> list = structureRepository.getProjectList();
if (securitySettings.isGrantProjectViewToAll() || securityService.isGlobalFunctionGranted(ProjectList.class)) {
return list;
} else if (securityService.isLogged()) {
return list.stream().filter(p -> securityService.isProjectFunctionGranted(p.id(), ProjectView.class)).collect(Collectors.toList());
} else {
throw new AccessDeniedException("Authentication is required.");
}
}
use of net.nemerosa.ontrack.model.settings.SecuritySettings in project ontrack by nemerosa.
the class CachedSettingsServiceIT method cache_security_settings.
@Test
public void cache_security_settings() throws Exception {
asUser().with(GlobalSettings.class).call(() -> {
// Gets the initial settings
SecuritySettings s0 = settingsService.getCachedSettings(SecuritySettings.class);
// Gets them a second time
SecuritySettings s1 = settingsService.getCachedSettings(SecuritySettings.class);
assertSame("The instance must have been cached", s0, s1);
// Invalidates the cache
settingsService.invalidate(SecuritySettings.class);
// Gets this new version
SecuritySettings s2 = settingsService.getCachedSettings(SecuritySettings.class);
assertNotSame("The cached instance must have been discarded", s1, s2);
// End
return null;
});
}
Aggregations