Search in sources :

Example 11 with DtDefinition

use of io.vertigo.dynamo.domain.metamodel.DtDefinition in project vertigo by KleeGroup.

the class MemoryAccountCachePlugin method putGroup.

/**
 * {@inheritDoc}
 */
@Override
public synchronized void putGroup(final AccountGroup group) {
    Assertion.checkNotNull(group);
    // -----
    final DtDefinition dtDefinition = DtObjectUtil.findDtDefinition(group);
    final URI<AccountGroup> uri = new URI<>(dtDefinition, group.getId());
    // ----
    Assertion.checkArgument(!groupByURI.containsKey(uri), "this group is already registered, you can't create it");
    // -----
    accountByGroupURI.put(uri, new HashSet<URI<Account>>());
    groupByURI.put(uri, group);
}
Also used : AccountGroup(io.vertigo.account.account.AccountGroup) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) URI(io.vertigo.dynamo.domain.model.URI)

Example 12 with DtDefinition

use of io.vertigo.dynamo.domain.metamodel.DtDefinition in project vertigo by KleeGroup.

the class SecuredEntityDeserializer method deserializeSecurityDimensions.

private static SecurityDimension deserializeSecurityDimensions(final DtDefinition entityDefinition, final JsonObject advancedDimension, final JsonDeserializationContext context) {
    final String name = advancedDimension.get("name").getAsString();
    final SecurityDimensionType type = SecurityDimensionType.valueOf(advancedDimension.get("type").getAsString());
    final List<String> fieldNames = deserializeList(advancedDimension.get("fields"), String.class, context);
    final List<DtField> fields = fieldNames.stream().map(fieldName -> deserializeDtField(entityDefinition, fieldName)).collect(Collectors.toList());
    final List<String> values = deserializeList(advancedDimension.get("values"), String.class, context);
    return new SecurityDimension(name, type, fields, values);
}
Also used : JsonObject(com.google.gson.JsonObject) RuleMultiExpression(io.vertigo.account.authorization.metamodel.rulemodel.RuleMultiExpression) DtField(io.vertigo.dynamo.domain.metamodel.DtField) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) JsonDeserializationContext(com.google.gson.JsonDeserializationContext) JsonElement(com.google.gson.JsonElement) Home(io.vertigo.app.Home) WrappedException(io.vertigo.lang.WrappedException) Map(java.util.Map) Assertion(io.vertigo.lang.Assertion) SecuredEntity(io.vertigo.account.authorization.metamodel.SecuredEntity) SecurityDimensionType(io.vertigo.account.authorization.metamodel.SecurityDimensionType) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) Set(java.util.Set) DslParserUtil(io.vertigo.account.impl.authorization.dsl.rules.DslParserUtil) Collectors(java.util.stream.Collectors) Definition(io.vertigo.core.definition.Definition) List(java.util.List) DefinitionUtil(io.vertigo.core.definition.DefinitionUtil) Type(java.lang.reflect.Type) StringUtil(io.vertigo.util.StringUtil) JsonDeserializer(com.google.gson.JsonDeserializer) Optional(java.util.Optional) Authorization(io.vertigo.account.authorization.metamodel.Authorization) PegNoMatchFoundException(io.vertigo.commons.peg.PegNoMatchFoundException) Collections(java.util.Collections) SecurityDimension(io.vertigo.account.authorization.metamodel.SecurityDimension) SecurityDimension(io.vertigo.account.authorization.metamodel.SecurityDimension) SecurityDimensionType(io.vertigo.account.authorization.metamodel.SecurityDimensionType) DtField(io.vertigo.dynamo.domain.metamodel.DtField)

Example 13 with DtDefinition

use of io.vertigo.dynamo.domain.metamodel.DtDefinition in project vertigo by KleeGroup.

the class LdapIdentityProviderPlugin method start.

/**
 * {@inheritDoc}
 */
@Override
public void start() {
    final DtDefinition userDtDefinition = Home.getApp().getDefinitionSpace().resolve(userDtDefinitionName, DtDefinition.class);
    mapperHelper = new AccountMapperHelper(userDtDefinition, ldapUserAttributeMappingStr).withReservedDestField(PHOTO_RESERVED_FIELD).parseAttributeMapping();
}
Also used : DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) AccountMapperHelper(io.vertigo.account.impl.account.AccountMapperHelper)

Example 14 with DtDefinition

use of io.vertigo.dynamo.domain.metamodel.DtDefinition in project vertigo by KleeGroup.

the class TextIdentityProviderPlugin method start.

/**
 * {@inheritDoc}
 */
@Override
public void start() {
    final DtDefinition userDtDefinition = Home.getApp().getDefinitionSpace().resolve(userDtDefinitionName, DtDefinition.class);
    Assertion.checkState(userDtDefinition.contains(userAuthTokenFieldName), "User definition ({0}) should contains the userAuthTokenField ({1})", userDtDefinitionName, userAuthTokenFieldName);
    final URL realmURL = resourceManager.resolve(filePath);
    try {
        final String confTest = parseFile(realmURL);
        try (final Scanner scanner = new Scanner(confTest)) {
            while (scanner.hasNextLine()) {
                final String line = scanner.nextLine();
                parseUserInfo(line, userDtDefinition);
            }
        }
    } catch (final Exception e) {
        throw WrappedException.wrap(e, "Erreur durant la lecture du Realm " + realmURL);
    }
}
Also used : Scanner(java.util.Scanner) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) URL(java.net.URL) WrappedException(io.vertigo.lang.WrappedException) FormatterException(io.vertigo.dynamo.domain.metamodel.FormatterException) IOException(java.io.IOException)

Example 15 with DtDefinition

use of io.vertigo.dynamo.domain.metamodel.DtDefinition 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)

Aggregations

DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)91 DtField (io.vertigo.dynamo.domain.metamodel.DtField)29 Test (org.junit.Test)21 URI (io.vertigo.dynamo.domain.model.URI)18 List (java.util.List)17 ArrayList (java.util.ArrayList)16 Assertion (io.vertigo.lang.Assertion)12 Collectors (java.util.stream.Collectors)11 Home (io.vertigo.app.Home)10 Optional (java.util.Optional)10 Domain (io.vertigo.dynamo.domain.metamodel.Domain)9 Collections (java.util.Collections)8 DefinitionUtil (io.vertigo.core.definition.DefinitionUtil)7 DtObjectUtil (io.vertigo.dynamo.domain.util.DtObjectUtil)7 TaskDefinition (io.vertigo.dynamo.task.metamodel.TaskDefinition)7 Inject (javax.inject.Inject)7 Authorization (io.vertigo.account.authorization.metamodel.Authorization)6 SecuredEntity (io.vertigo.account.authorization.metamodel.SecuredEntity)6 Criterions (io.vertigo.dynamo.criteria.Criterions)6 DefinitionSpace (io.vertigo.core.definition.DefinitionSpace)5