Search in sources :

Example 6 with RuleMultiExpression

use of io.vertigo.account.authorization.metamodel.rulemodel.RuleMultiExpression in project vertigo by KleeGroup.

the class CriteriaSecurityRuleTranslator method toCriteria.

private Criteria<E> toCriteria(final RuleMultiExpression multiExpression) {
    if (multiExpression.isAlwaysTrue()) {
        return Criterions.alwaysTrue();
    }
    Criteria<E> mainCriteria = null;
    for (final RuleExpression expression : multiExpression.getExpressions()) {
        if (multiExpression.getBoolOperator() == BoolOperator.AND) {
            mainCriteria = andCriteria(mainCriteria, toCriteria(expression));
        } else {
            mainCriteria = orCriteria(mainCriteria, toCriteria(expression));
        }
    }
    for (final RuleMultiExpression expression : multiExpression.getMultiExpressions()) {
        if (multiExpression.getBoolOperator() == BoolOperator.AND) {
            mainCriteria = andCriteria(mainCriteria, toCriteria(expression));
        } else {
            mainCriteria = orCriteria(mainCriteria, toCriteria(expression));
        }
    }
    // can be null ?
    Assertion.checkNotNull(mainCriteria);
    return mainCriteria;
}
Also used : RuleExpression(io.vertigo.account.authorization.metamodel.rulemodel.RuleExpression) RuleMultiExpression(io.vertigo.account.authorization.metamodel.rulemodel.RuleMultiExpression)

Example 7 with RuleMultiExpression

use of io.vertigo.account.authorization.metamodel.rulemodel.RuleMultiExpression in project vertigo by KleeGroup.

the class CriteriaSecurityRuleTranslator method toCriteria.

/**
 * @return This security rule as search Query
 */
public Criteria<E> toCriteria() {
    Criteria<E> mainCriteria = null;
    for (final RuleMultiExpression expression : getMultiExpressions()) {
        mainCriteria = orCriteria(mainCriteria, toCriteria(expression));
    }
    // can't be null
    Assertion.checkNotNull(mainCriteria);
    return mainCriteria;
}
Also used : RuleMultiExpression(io.vertigo.account.authorization.metamodel.rulemodel.RuleMultiExpression)

Example 8 with RuleMultiExpression

use of io.vertigo.account.authorization.metamodel.rulemodel.RuleMultiExpression in project vertigo by KleeGroup.

the class SearchSecurityRuleTranslator method buildQueryString.

private String buildQueryString() {
    final StringBuilder query = new StringBuilder();
    String sep = "";
    for (final RuleMultiExpression multiExpressionDefinition : getMultiExpressions()) {
        // On ajoute cette parenthèse car le premier niveau de multiExpression est en OR
        query.append(sep).append('(');
        appendMultiExpression(query, multiExpressionDefinition);
        query.append(')');
        sep = DEFAULT_BOOL_SEP;
    }
    return query.toString().replaceAll("^\\s+", // replace whitespaces at beginning of a line
    "").replaceAll("\\s+$", // replace whitespaces at end of a line
    "").replaceAll("\\s+", // replace multiple whitespaces by space
    " ").replaceAll("^\\(\\)$", // replace empty query to all
    "(*:*)");
}
Also used : RuleMultiExpression(io.vertigo.account.authorization.metamodel.rulemodel.RuleMultiExpression)

Example 9 with RuleMultiExpression

use of io.vertigo.account.authorization.metamodel.rulemodel.RuleMultiExpression in project vertigo by KleeGroup.

the class SqlSecurityRuleTranslator method buildQueryString.

private String buildQueryString() {
    final StringBuilder query = new StringBuilder();
    String sep = "";
    for (final RuleMultiExpression multiExpressionDefinition : getMultiExpressions()) {
        query.append(sep);
        appendMultiExpression(query, multiExpressionDefinition);
        sep = DEFAULT_BOOL_SEP;
    }
    return query.toString().replaceAll("^\\s+", // replace whitespaces at beginning of a line
    "").replaceAll("\\s+$", // replace whitespaces at end of a line
    "").replaceAll("\\s+", // replace multiple whitespaces by space
    " ");
}
Also used : RuleMultiExpression(io.vertigo.account.authorization.metamodel.rulemodel.RuleMultiExpression)

Aggregations

RuleMultiExpression (io.vertigo.account.authorization.metamodel.rulemodel.RuleMultiExpression)9 RuleExpression (io.vertigo.account.authorization.metamodel.rulemodel.RuleExpression)4 List (java.util.List)2 AuthorizationManager (io.vertigo.account.authorization.AuthorizationManager)1 UserAuthorizations (io.vertigo.account.authorization.UserAuthorizations)1 Authorization (io.vertigo.account.authorization.metamodel.Authorization)1 AuthorizationName (io.vertigo.account.authorization.metamodel.AuthorizationName)1 OperationName (io.vertigo.account.authorization.metamodel.OperationName)1 SecuredEntity (io.vertigo.account.authorization.metamodel.SecuredEntity)1 BoolOperator (io.vertigo.account.authorization.metamodel.rulemodel.RuleMultiExpression.BoolOperator)1 CriteriaSecurityRuleTranslator (io.vertigo.account.impl.authorization.dsl.translator.CriteriaSecurityRuleTranslator)1 SearchSecurityRuleTranslator (io.vertigo.account.impl.authorization.dsl.translator.SearchSecurityRuleTranslator)1 Home (io.vertigo.app.Home)1 PegChoice (io.vertigo.commons.peg.PegChoice)1 PegNoMatchFoundException (io.vertigo.commons.peg.PegNoMatchFoundException)1 DefinitionUtil (io.vertigo.core.definition.DefinitionUtil)1 Criteria (io.vertigo.dynamo.criteria.Criteria)1 Criterions (io.vertigo.dynamo.criteria.Criterions)1 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)1 KeyConcept (io.vertigo.dynamo.domain.model.KeyConcept)1