Search in sources :

Example 1 with Configuration

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;
}
Also used : ActionConfig(com.opensymphony.xwork2.config.entities.ActionConfig) Configuration(com.opensymphony.xwork2.config.Configuration) PackageConfig(com.opensymphony.xwork2.config.entities.PackageConfig) HashSet(java.util.HashSet)

Example 2 with Configuration

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;
    }
}
Also used : ActionConfig(com.opensymphony.xwork2.config.entities.ActionConfig) AccessDeniedException(org.springframework.security.access.AccessDeniedException) Configuration(com.opensymphony.xwork2.config.Configuration) SecurityMetadataSource(org.springframework.security.access.SecurityMetadataSource) Authentication(org.springframework.security.core.Authentication) SecurityContext(org.springframework.security.core.context.SecurityContext) InsufficientAuthenticationException(org.springframework.security.authentication.InsufficientAuthenticationException) PackageConfig(com.opensymphony.xwork2.config.entities.PackageConfig)

Example 3 with Configuration

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();
}
Also used : Configuration(com.opensymphony.xwork2.config.Configuration) PackageConfig(com.opensymphony.xwork2.config.entities.PackageConfig)

Example 4 with Configuration

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);
}
Also used : Configuration(Config.Configuration)

Example 5 with Configuration

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);
}
Also used : Configuration(Config.Configuration)

Aggregations

Configuration (com.opensymphony.xwork2.config.Configuration)3 PackageConfig (com.opensymphony.xwork2.config.entities.PackageConfig)3 Configuration (Config.Configuration)2 ActionConfig (com.opensymphony.xwork2.config.entities.ActionConfig)2 HashSet (java.util.HashSet)1 AccessDeniedException (org.springframework.security.access.AccessDeniedException)1 SecurityMetadataSource (org.springframework.security.access.SecurityMetadataSource)1 InsufficientAuthenticationException (org.springframework.security.authentication.InsufficientAuthenticationException)1 Authentication (org.springframework.security.core.Authentication)1 SecurityContext (org.springframework.security.core.context.SecurityContext)1