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);
}
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);
}
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();
}
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);
}
}
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));
}
Aggregations