Search in sources :

Example 1 with KeyConcept

use of io.vertigo.dynamo.domain.model.KeyConcept in project vertigo by KleeGroup.

the class AbstractESSearchServicesPlugin method loadList.

/**
 * {@inheritDoc}
 */
@Override
public final <R extends DtObject> FacetedQueryResult<R, SearchQuery> loadList(final SearchIndexDefinition indexDefinition, final SearchQuery searchQuery, final DtListState listState) {
    Assertion.checkNotNull(searchQuery);
    // -----
    final ESStatement<KeyConcept, R> statement = createElasticStatement(indexDefinition);
    final DtListState usedListState = listState != null ? listState : defaultListState;
    return statement.loadList(indexDefinition, searchQuery, usedListState, defaultMaxRows);
}
Also used : KeyConcept(io.vertigo.dynamo.domain.model.KeyConcept) DtListState(io.vertigo.dynamo.domain.model.DtListState)

Example 2 with KeyConcept

use of io.vertigo.dynamo.domain.model.KeyConcept in project vertigo by KleeGroup.

the class AuthorizationManagerImpl method isAuthorized.

/**
 * {@inheritDoc}
 */
@Override
public <K extends KeyConcept> boolean isAuthorized(final K keyConcept, final OperationName<K> operationName) {
    Assertion.checkNotNull(keyConcept);
    Assertion.checkNotNull(operationName);
    // ---
    final Optional<UserAuthorizations> userPermissionsOpt = getUserPermissionsOpt();
    if (!userPermissionsOpt.isPresent()) {
        // Si il n'y a pas de session alors pas d'autorisation.
        return false;
    }
    final UserAuthorizations userPermissions = userPermissionsOpt.get();
    final DtDefinition dtDefinition = DtObjectUtil.findDtDefinition(keyConcept);
    final SecuredEntity securedEntity = findSecuredEntity(dtDefinition);
    return userPermissions.getEntityAuthorizations(dtDefinition).stream().filter(permission -> permission.getOperation().get().equals(operationName.name()) || permission.getOverrides().contains(operationName.name())).flatMap(permission -> permission.getRules().stream()).anyMatch(rule -> new CriteriaSecurityRuleTranslator<K>().on(securedEntity).withRule(rule).withCriteria(userPermissions.getSecurityKeys()).toCriteria().toPredicate().test(keyConcept));
}
Also used : RuleMultiExpression(io.vertigo.account.authorization.metamodel.rulemodel.RuleMultiExpression) CriteriaSecurityRuleTranslator(io.vertigo.account.impl.authorization.dsl.translator.CriteriaSecurityRuleTranslator) VSecurityManager(io.vertigo.persona.security.VSecurityManager) UserAuthorizations(io.vertigo.account.authorization.UserAuthorizations) AuthorizationName(io.vertigo.account.authorization.metamodel.AuthorizationName) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) DtObjectUtil(io.vertigo.dynamo.domain.util.DtObjectUtil) Criteria(io.vertigo.dynamo.criteria.Criteria) AuthorizationManager(io.vertigo.account.authorization.AuthorizationManager) Collectors(java.util.stream.Collectors) Inject(javax.inject.Inject) Home(io.vertigo.app.Home) List(java.util.List) DefinitionUtil(io.vertigo.core.definition.DefinitionUtil) Criterions(io.vertigo.dynamo.criteria.Criterions) Assertion(io.vertigo.lang.Assertion) KeyConcept(io.vertigo.dynamo.domain.model.KeyConcept) Optional(java.util.Optional) Authorization(io.vertigo.account.authorization.metamodel.Authorization) OperationName(io.vertigo.account.authorization.metamodel.OperationName) Collections(java.util.Collections) SearchSecurityRuleTranslator(io.vertigo.account.impl.authorization.dsl.translator.SearchSecurityRuleTranslator) UserSession(io.vertigo.persona.security.UserSession) SecuredEntity(io.vertigo.account.authorization.metamodel.SecuredEntity) SecuredEntity(io.vertigo.account.authorization.metamodel.SecuredEntity) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) UserAuthorizations(io.vertigo.account.authorization.UserAuthorizations)

Example 3 with KeyConcept

use of io.vertigo.dynamo.domain.model.KeyConcept in project vertigo by KleeGroup.

the class AuthorizationManagerImpl method getAuthorizedOperations.

/**
 * {@inheritDoc}
 */
@Override
public <K extends KeyConcept> List<String> getAuthorizedOperations(final K keyConcept) {
    Assertion.checkNotNull(keyConcept);
    // ---
    final Optional<UserAuthorizations> userPermissionsOpt = getUserPermissionsOpt();
    if (!userPermissionsOpt.isPresent()) {
        // Si il n'y a pas de session alors pas d'autorisation.
        return Collections.emptyList();
    }
    final DtDefinition dtDefinition = DtObjectUtil.findDtDefinition(keyConcept);
    return userPermissionsOpt.get().getEntityAuthorizations(dtDefinition).stream().map(permission -> permission.getOperation().get()).collect(Collectors.toList());
}
Also used : RuleMultiExpression(io.vertigo.account.authorization.metamodel.rulemodel.RuleMultiExpression) CriteriaSecurityRuleTranslator(io.vertigo.account.impl.authorization.dsl.translator.CriteriaSecurityRuleTranslator) VSecurityManager(io.vertigo.persona.security.VSecurityManager) UserAuthorizations(io.vertigo.account.authorization.UserAuthorizations) AuthorizationName(io.vertigo.account.authorization.metamodel.AuthorizationName) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) DtObjectUtil(io.vertigo.dynamo.domain.util.DtObjectUtil) Criteria(io.vertigo.dynamo.criteria.Criteria) AuthorizationManager(io.vertigo.account.authorization.AuthorizationManager) Collectors(java.util.stream.Collectors) Inject(javax.inject.Inject) Home(io.vertigo.app.Home) List(java.util.List) DefinitionUtil(io.vertigo.core.definition.DefinitionUtil) Criterions(io.vertigo.dynamo.criteria.Criterions) Assertion(io.vertigo.lang.Assertion) KeyConcept(io.vertigo.dynamo.domain.model.KeyConcept) Optional(java.util.Optional) Authorization(io.vertigo.account.authorization.metamodel.Authorization) OperationName(io.vertigo.account.authorization.metamodel.OperationName) Collections(java.util.Collections) SearchSecurityRuleTranslator(io.vertigo.account.impl.authorization.dsl.translator.SearchSecurityRuleTranslator) UserSession(io.vertigo.persona.security.UserSession) SecuredEntity(io.vertigo.account.authorization.metamodel.SecuredEntity) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) UserAuthorizations(io.vertigo.account.authorization.UserAuthorizations)

Example 4 with KeyConcept

use of io.vertigo.dynamo.domain.model.KeyConcept in project vertigo by KleeGroup.

the class SearchManagerImpl method start.

/**
 * {@inheritDoc}
 */
@Override
public void start() {
    for (final SearchIndexDefinition indexDefinition : Home.getApp().getDefinitionSpace().getAll(SearchIndexDefinition.class)) {
        final List<URI<? extends KeyConcept>> dirtyElements = new ArrayList<>();
        dirtyElementsPerIndexName.put(indexDefinition.getName(), dirtyElements);
        // on dépile les dirtyElements toutes les 1 secondes
        executorService.scheduleWithFixedDelay(new ReindexTask(indexDefinition, dirtyElements, this), 1, 1, TimeUnit.SECONDS);
    }
}
Also used : KeyConcept(io.vertigo.dynamo.domain.model.KeyConcept) SearchIndexDefinition(io.vertigo.dynamo.search.metamodel.SearchIndexDefinition) ArrayList(java.util.ArrayList) URI(io.vertigo.dynamo.domain.model.URI)

Example 5 with KeyConcept

use of io.vertigo.dynamo.domain.model.KeyConcept in project vertigo by KleeGroup.

the class AuthorizationManagerImpl method getCriteriaSecurity.

/**
 * {@inheritDoc}
 */
@Override
public <K extends KeyConcept> Criteria<K> getCriteriaSecurity(final Class<K> keyConceptClass, final OperationName<K> operation) {
    Assertion.checkNotNull(keyConceptClass);
    Assertion.checkNotNull(operation);
    // ---
    final Optional<UserAuthorizations> userPermissionsOpt = getUserPermissionsOpt();
    if (!userPermissionsOpt.isPresent()) {
        // Si il n'y a pas de session alors pas d'autorisation.
        return Criterions.alwaysFalse();
    }
    final UserAuthorizations userPermissions = userPermissionsOpt.get();
    final DtDefinition dtDefinition = DtObjectUtil.findDtDefinition(keyConceptClass);
    final SecuredEntity securedEntity = findSecuredEntity(dtDefinition);
    final List<Criteria<K>> criterions = userPermissions.getEntityAuthorizations(dtDefinition).stream().filter(permission -> permission.getOperation().get().equals(operation.name()) || permission.getOverrides().contains(operation.name())).flatMap(permission -> permission.getRules().stream()).map(rule -> new CriteriaSecurityRuleTranslator<K>().on(securedEntity).withRule(rule).withCriteria(userPermissions.getSecurityKeys()).toCriteria()).collect(Collectors.toList());
    if (criterions.isEmpty()) {
        // Si il n'y a pas de droits alors pas d'autorisation.
        return Criterions.alwaysFalse();
    }
    Criteria<K> securityCriteria = null;
    for (final Criteria<K> ruleCriteria : criterions) {
        if (securityCriteria == null) {
            securityCriteria = ruleCriteria;
        } else {
            securityCriteria = securityCriteria.or(ruleCriteria);
        }
    }
    return securityCriteria;
}
Also used : RuleMultiExpression(io.vertigo.account.authorization.metamodel.rulemodel.RuleMultiExpression) CriteriaSecurityRuleTranslator(io.vertigo.account.impl.authorization.dsl.translator.CriteriaSecurityRuleTranslator) VSecurityManager(io.vertigo.persona.security.VSecurityManager) UserAuthorizations(io.vertigo.account.authorization.UserAuthorizations) AuthorizationName(io.vertigo.account.authorization.metamodel.AuthorizationName) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) DtObjectUtil(io.vertigo.dynamo.domain.util.DtObjectUtil) Criteria(io.vertigo.dynamo.criteria.Criteria) AuthorizationManager(io.vertigo.account.authorization.AuthorizationManager) Collectors(java.util.stream.Collectors) Inject(javax.inject.Inject) Home(io.vertigo.app.Home) List(java.util.List) DefinitionUtil(io.vertigo.core.definition.DefinitionUtil) Criterions(io.vertigo.dynamo.criteria.Criterions) Assertion(io.vertigo.lang.Assertion) KeyConcept(io.vertigo.dynamo.domain.model.KeyConcept) Optional(java.util.Optional) Authorization(io.vertigo.account.authorization.metamodel.Authorization) OperationName(io.vertigo.account.authorization.metamodel.OperationName) Collections(java.util.Collections) SearchSecurityRuleTranslator(io.vertigo.account.impl.authorization.dsl.translator.SearchSecurityRuleTranslator) UserSession(io.vertigo.persona.security.UserSession) SecuredEntity(io.vertigo.account.authorization.metamodel.SecuredEntity) SecuredEntity(io.vertigo.account.authorization.metamodel.SecuredEntity) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) CriteriaSecurityRuleTranslator(io.vertigo.account.impl.authorization.dsl.translator.CriteriaSecurityRuleTranslator) Criteria(io.vertigo.dynamo.criteria.Criteria) UserAuthorizations(io.vertigo.account.authorization.UserAuthorizations)

Aggregations

KeyConcept (io.vertigo.dynamo.domain.model.KeyConcept)10 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)5 AuthorizationManager (io.vertigo.account.authorization.AuthorizationManager)4 UserAuthorizations (io.vertigo.account.authorization.UserAuthorizations)4 Authorization (io.vertigo.account.authorization.metamodel.Authorization)4 AuthorizationName (io.vertigo.account.authorization.metamodel.AuthorizationName)4 OperationName (io.vertigo.account.authorization.metamodel.OperationName)4 SecuredEntity (io.vertigo.account.authorization.metamodel.SecuredEntity)4 RuleMultiExpression (io.vertigo.account.authorization.metamodel.rulemodel.RuleMultiExpression)4 CriteriaSecurityRuleTranslator (io.vertigo.account.impl.authorization.dsl.translator.CriteriaSecurityRuleTranslator)4 SearchSecurityRuleTranslator (io.vertigo.account.impl.authorization.dsl.translator.SearchSecurityRuleTranslator)4 Home (io.vertigo.app.Home)4 DefinitionUtil (io.vertigo.core.definition.DefinitionUtil)4 Criteria (io.vertigo.dynamo.criteria.Criteria)4 Criterions (io.vertigo.dynamo.criteria.Criterions)4 URI (io.vertigo.dynamo.domain.model.URI)4 DtObjectUtil (io.vertigo.dynamo.domain.util.DtObjectUtil)4 Assertion (io.vertigo.lang.Assertion)4 UserSession (io.vertigo.persona.security.UserSession)4 VSecurityManager (io.vertigo.persona.security.VSecurityManager)4