use of Config.Configuration in project dhis2-core by dhis2.
the class DetectingSystemAuthoritiesProvider method getSystemAuthorities.
// -------------------------------------------------------------------------
// SystemAuthoritiesProvider implementation
// -------------------------------------------------------------------------
@Override
public Collection<String> getSystemAuthorities() {
HashSet<String> authorities = new HashSet<>();
Configuration configuration = Dispatcher.getInstance().getConfigurationManager().getConfiguration();
for (PackageConfig packageConfig : configuration.getPackageConfigs().values()) {
for (ActionConfig actionConfig : packageConfig.getActionConfigs().values()) {
authorities.addAll(requiredAuthoritiesProvider.getAllAuthorities(actionConfig));
}
}
return authorities;
}
use of Config.Configuration in project dhis2-core by dhis2.
the class SpringSecurityActionAccessResolver method hasAccess.
// -------------------------------------------------------------------------
// ActionAccessResolver implementation
// -------------------------------------------------------------------------
@Override
public boolean hasAccess(String module, String name) {
// ---------------------------------------------------------------------
// Get ObjectDefinitionSource
// ---------------------------------------------------------------------
Configuration config = Dispatcher.getInstance().getConfigurationManager().getConfiguration();
PackageConfig packageConfig = config.getPackageConfig(module);
if (packageConfig == null) {
throw new IllegalArgumentException("Module doesn't exist: '" + module + "'");
}
ActionConfig actionConfig = packageConfig.getActionConfigs().get(name);
if (actionConfig == null) {
throw new IllegalArgumentException("Module " + module + " doesn't have an action named: '" + name + "'");
}
SecurityMetadataSource securityMetadataSource = requiredAuthoritiesProvider.createSecurityMetadataSource(actionConfig);
// ---------------------------------------------------------------------
// Test access
// ---------------------------------------------------------------------
SecurityContext securityContext = SecurityContextHolder.getContext();
Authentication authentication = securityContext.getAuthentication();
try {
if (securityMetadataSource.getAttributes(actionConfig) != null) {
if (authentication == null || !authentication.isAuthenticated()) {
return false;
}
accessDecisionManager.decide(authentication, actionConfig, securityMetadataSource.getAttributes(actionConfig));
}
log.debug("Access to [" + module + ", " + name + "]: TRUE");
return true;
} catch (AccessDeniedException e) {
log.debug("Access to [" + module + ", " + name + "]: FALSE (access denied)");
return false;
} catch (InsufficientAuthenticationException e) {
log.debug("Access to [" + module + ", " + name + "]: FALSE (insufficient authentication)");
return false;
}
}
use of Config.Configuration in project dhis2-core by dhis2.
the class DefaultModuleManager method getPackageConfigs.
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
private Collection<PackageConfig> getPackageConfigs() {
Configuration configuration = Dispatcher.getInstance().getConfigurationManager().getConfiguration();
Map<String, PackageConfig> packageConfigs = configuration.getPackageConfigs();
return packageConfigs.values();
}
use of Config.Configuration in project benchmarx by eMoflon.
the class MediniQVTFamiliesToPersonsConfig method launchFWD.
private void launchFWD() {
Configuration configuration = (Configuration) config.getContents().get(0);
// Set direction in the configuration model
configuration.setFromPersonsToFamilies(false);
launch(fwdDir);
}
use of Config.Configuration in project benchmarx by eMoflon.
the class MediniQVTFamiliesToPersonsConfig method launchBWD.
private void launchBWD() {
Configuration configuration = (Configuration) config.getContents().get(0);
// Set direction in the configuration model
configuration.setFromPersonsToFamilies(true);
// Copy configuration parameters into configuration model
boolean preferCreatingParentToChild = configurator.decide(Decisions.PREFER_CREATING_PARENT_TO_CHILD);
configuration.setPreferParentToChild(preferCreatingParentToChild);
boolean preferExistingFamilyToNew = configurator.decide(Decisions.PREFER_EXISTING_FAMILY_TO_NEW);
configuration.setPreferExistingToNewFamily(preferExistingFamilyToNew);
launch(bwdDir);
}
Aggregations