Search in sources :

Example 1 with Config

use of com.yahoo.elide.modelconfig.Config in project elide by yahoo.

the class DynamicConfigValidator method readSecurityConfig.

/**
 * Read and validates security config file.
 */
private ElideSecurityConfig readSecurityConfig(Map<String, ConfigFile> resourceMap) {
    return resourceMap.entrySet().stream().filter(entry -> entry.getKey().startsWith(Config.SECURITY.getConfigPath())).map(entry -> {
        try {
            String content = entry.getValue().getContent();
            validateConfigForMissingVariables(content, this.modelVariables);
            return DynamicConfigHelpers.stringToElideSecurityPojo(entry.getKey(), content, this.modelVariables, schemaValidator);
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
    }).findAny().orElse(new ElideSecurityConfig());
}
Also used : Arrays(java.util.Arrays) DynamicConfiguration(com.yahoo.elide.modelconfig.DynamicConfiguration) Include(com.yahoo.elide.annotation.Include) FileLoader(com.yahoo.elide.modelconfig.io.FileLoader) DefaultParser(org.apache.commons.cli.DefaultParser) Matcher(java.util.regex.Matcher) ClassScanner(com.yahoo.elide.core.utils.ClassScanner) Locale(java.util.Locale) Map(java.util.Map) DynamicConfigHelpers(com.yahoo.elide.modelconfig.DynamicConfigHelpers) Named(com.yahoo.elide.modelconfig.model.Named) Join(com.yahoo.elide.modelconfig.model.Join) TableSource(com.yahoo.elide.modelconfig.model.TableSource) ElideSecurityConfig(com.yahoo.elide.modelconfig.model.ElideSecurityConfig) Argument(com.yahoo.elide.modelconfig.model.Argument) DefaultClassScanner(com.yahoo.elide.core.utils.DefaultClassScanner) Collection(java.util.Collection) Set(java.util.Set) Collectors(java.util.stream.Collectors) EntityDictionary(com.yahoo.elide.core.dictionary.EntityDictionary) SecurityCheck(com.yahoo.elide.annotation.SecurityCheck) Objects(java.util.Objects) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) StringUtils.isNotBlank(org.apache.commons.lang3.StringUtils.isNotBlank) Stream(java.util.stream.Stream) DynamicConfigSchemaValidator(com.yahoo.elide.modelconfig.DynamicConfigSchemaValidator) Pattern(java.util.regex.Pattern) NamespaceConfig(com.yahoo.elide.modelconfig.model.NamespaceConfig) Getter(lombok.Getter) ElideTableConfig(com.yahoo.elide.modelconfig.model.ElideTableConfig) Table(com.yahoo.elide.modelconfig.model.Table) ConfigFile(com.yahoo.elide.modelconfig.store.models.ConfigFile) Options(org.apache.commons.cli.Options) ElideDBConfig(com.yahoo.elide.modelconfig.model.ElideDBConfig) HashMap(java.util.HashMap) UserCheck(com.yahoo.elide.core.security.checks.UserCheck) ElideNamespaceConfig(com.yahoo.elide.modelconfig.model.ElideNamespaceConfig) HelpFormatter(org.apache.commons.cli.HelpFormatter) ElideSQLDBConfig(com.yahoo.elide.modelconfig.model.ElideSQLDBConfig) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) CollectionUtils(org.apache.commons.collections.CollectionUtils) NO_VERSION(com.yahoo.elide.core.dictionary.EntityDictionary.NO_VERSION) Config(com.yahoo.elide.modelconfig.Config) CommandLine(org.apache.commons.cli.CommandLine) ParseTree(org.antlr.v4.runtime.tree.ParseTree) FilterExpressionCheck(com.yahoo.elide.core.security.checks.FilterExpressionCheck) Option(org.apache.commons.cli.Option) Check(com.yahoo.elide.core.security.checks.Check) Dimension(com.yahoo.elide.modelconfig.model.Dimension) IOException(java.io.IOException) DBConfig(com.yahoo.elide.modelconfig.model.DBConfig) BadRequestException(com.yahoo.elide.core.exceptions.BadRequestException) StringUtils.isBlank(org.apache.commons.lang3.StringUtils.isBlank) EntityPermissions(com.yahoo.elide.core.dictionary.EntityPermissions) Type(com.yahoo.elide.core.type.Type) Collections(java.util.Collections) Measure(com.yahoo.elide.modelconfig.model.Measure) ElideSecurityConfig(com.yahoo.elide.modelconfig.model.ElideSecurityConfig) IOException(java.io.IOException)

Aggregations

Include (com.yahoo.elide.annotation.Include)1 SecurityCheck (com.yahoo.elide.annotation.SecurityCheck)1 EntityDictionary (com.yahoo.elide.core.dictionary.EntityDictionary)1 NO_VERSION (com.yahoo.elide.core.dictionary.EntityDictionary.NO_VERSION)1 EntityPermissions (com.yahoo.elide.core.dictionary.EntityPermissions)1 BadRequestException (com.yahoo.elide.core.exceptions.BadRequestException)1 Check (com.yahoo.elide.core.security.checks.Check)1 FilterExpressionCheck (com.yahoo.elide.core.security.checks.FilterExpressionCheck)1 UserCheck (com.yahoo.elide.core.security.checks.UserCheck)1 Type (com.yahoo.elide.core.type.Type)1 ClassScanner (com.yahoo.elide.core.utils.ClassScanner)1 DefaultClassScanner (com.yahoo.elide.core.utils.DefaultClassScanner)1 Config (com.yahoo.elide.modelconfig.Config)1 DynamicConfigHelpers (com.yahoo.elide.modelconfig.DynamicConfigHelpers)1 DynamicConfigSchemaValidator (com.yahoo.elide.modelconfig.DynamicConfigSchemaValidator)1 DynamicConfiguration (com.yahoo.elide.modelconfig.DynamicConfiguration)1 FileLoader (com.yahoo.elide.modelconfig.io.FileLoader)1 Argument (com.yahoo.elide.modelconfig.model.Argument)1 DBConfig (com.yahoo.elide.modelconfig.model.DBConfig)1 Dimension (com.yahoo.elide.modelconfig.model.Dimension)1