use of eu.bcvsolutions.idm.acc.domain.SystemEntityType in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemAttributeMappingServiceTest method moreAttributesOnSchemaAttributeProvTest.
@Test(expected = ResultCodeException.class)
public void moreAttributesOnSchemaAttributeProvTest() {
SystemEntityType entityType = SystemEntityType.IDENTITY;
AttributeMappingStrategyType strategyType = AttributeMappingStrategyType.SET;
SysSystemDto system = createSystem();
SysSchemaObjectClassDto objectClass = createObjectClass(system);
SysSystemMappingDto systemMapping = testHelper.createMappingSystem(entityType, objectClass);
// For provisioning is NOT enabled more mapped attributes for one schema
// attribute
systemMapping.setOperationType(SystemOperationType.PROVISIONING);
systemMapping = mappingService.save(systemMapping);
SysSchemaAttributeDto schemaAttribute = createSchemaAttribute(objectClass);
SysSystemAttributeMappingDto attributeMapping1 = createAttributeMappingSystem(systemMapping, strategyType, schemaAttribute.getId());
attributeMapping1.setName("attributeOne");
attributeMapping1 = attributeMappingService.save(attributeMapping1);
SysSystemAttributeMappingDto attributeMapping2 = createAttributeMappingSystem(systemMapping, strategyType, schemaAttribute.getId());
attributeMapping2.setName("attributeTwo");
attributeMapping2 = attributeMappingService.save(attributeMapping2);
}
use of eu.bcvsolutions.idm.acc.domain.SystemEntityType in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemAttributeMappingServiceTest method systemMappingIdFilterTest.
@Test
public void systemMappingIdFilterTest() {
IdmBasePermission permission = IdmBasePermission.ADMIN;
SystemEntityType entityType = SystemEntityType.IDENTITY;
AttributeMappingStrategyType strategyType = AttributeMappingStrategyType.MERGE;
SysSystemDto system = createSystem();
SysSchemaObjectClassDto objectClass = createObjectClass(system);
SysSystemMappingDto systemMapping1 = testHelper.createMappingSystem(entityType, objectClass);
SysSystemMappingDto systemMapping2 = testHelper.createMappingSystem(entityType, objectClass);
SysSchemaAttributeDto schemaAttribute = createSchemaAttribute(objectClass);
SysSystemAttributeMappingDto attributeMapping1 = createAttributeMappingSystem(systemMapping1, strategyType, schemaAttribute.getId());
SysSystemAttributeMappingDto attributeMapping2 = createAttributeMappingSystem(systemMapping2, strategyType, schemaAttribute.getId());
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setSystemMappingId(systemMapping1.getId());
Page<SysSystemAttributeMappingDto> result = attributeMappingService.find(filter, null, permission);
assertEquals(1, result.getTotalElements());
assertTrue(result.getContent().contains(attributeMapping1));
assertFalse(result.getContent().contains(attributeMapping2));
}
use of eu.bcvsolutions.idm.acc.domain.SystemEntityType in project CzechIdMng by bcvsolutions.
the class AbstractProvisioningExecutor method doInternalProvisioning.
@Override
public SysProvisioningOperationDto doInternalProvisioning(AccAccountDto account, DTO dto, boolean isDryRun) {
Assert.notNull(account, "Account is required.");
Assert.notNull(dto, "DTO is required.");
//
ProvisioningOperationType operationType;
SysSystemDto system = DtoUtils.getEmbedded(account, AccAccount_.system);
SysSystemEntityDto systemEntity = getSystemEntity(account);
SystemEntityType entityType = SystemEntityType.getByClass(dto.getClass());
String uid = account.getUid();
//
if (systemEntity == null) {
// prepare system entity - uid could be changed by provisioning, but
// we need to link her with account
// First we try find system entity with same uid.
systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, entityType, uid);
if (systemEntity == null) {
systemEntity = new SysSystemEntityDto();
systemEntity.setEntityType(entityType);
systemEntity.setSystem(system.getId());
systemEntity.setUid(uid);
systemEntity.setWish(true);
systemEntity = systemEntityService.save(systemEntity);
}
account.setSystemEntity(systemEntity.getId());
account = accountService.save(account);
// we wont create account, but after target system call can be
// switched to UPDATE
operationType = ProvisioningOperationType.CREATE;
} else {
// we wont update account, but after target system call can be
// switched to CREATE
operationType = ProvisioningOperationType.UPDATE;
}
List<AttributeMapping> finalAttributes = resolveMappedAttributes(account, dto, system, systemEntity.getEntityType());
if (CollectionUtils.isEmpty(finalAttributes)) {
// nothing to do - mapping is empty
return null;
}
return doProvisioning(systemEntity, dto, dto.getId(), operationType, finalAttributes, isDryRun);
}
use of eu.bcvsolutions.idm.acc.domain.SystemEntityType in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemAttributeMappingService method getControlledAttributeValues.
@Override
public List<Serializable> getControlledAttributeValues(UUID systemId, SystemEntityType entityType, String schemaAttributeName) {
Assert.notNull(systemId, "System ID is mandatory for get controlled values!");
Assert.notNull(entityType, "Entity type is mandatory for get controlled values!");
Assert.notNull(schemaAttributeName, "Schema attribute name is mandatory for get controlled values!");
SysSystemMappingDto mapping = systemMappingService.findProvisioningMapping(systemId, entityType);
Assert.notNull(mapping, "System provisioning mapping is mandatory for search controlled attribute values!");
List<Serializable> results = Lists.newArrayList();
// Obtains controlled values from role-attributes
SysRoleSystemAttributeFilter roleSystemAttributeFilter = new SysRoleSystemAttributeFilter();
roleSystemAttributeFilter.setSystemMappingId(mapping.getId());
roleSystemAttributeFilter.setSchemaAttributeName(schemaAttributeName);
List<SysRoleSystemAttributeDto> roleSystemAttributes = roleSystemAttributeService.find(roleSystemAttributeFilter, null).getContent();
// We need values for merge and enabled attributes only
roleSystemAttributes.stream().filter(roleSystemAttr -> //
AttributeMappingStrategyType.MERGE == roleSystemAttr.getStrategyType() && //
!roleSystemAttr.isDisabledAttribute()).forEach(roleSystemAttr -> {
//
Serializable value = getControlledValue(roleSystemAttr, systemId, schemaAttributeName);
if (value != null && !results.contains(value)) {
results.add(value);
}
});
return results;
}
use of eu.bcvsolutions.idm.acc.domain.SystemEntityType in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningArchiveService method toPredicates.
@Override
protected List<Predicate> toPredicates(Root<SysProvisioningArchive> root, CriteriaQuery<?> query, CriteriaBuilder builder, SysProvisioningOperationFilter filter) {
List<Predicate> predicates = super.toPredicates(root, query, builder, filter);
// quick - "fulltext"
if (StringUtils.isNotEmpty(filter.getText())) {
throw new ResultCodeException(CoreResultCode.BAD_FILTER, "Filter by text is not supported.");
}
// System Id
UUID systemId = filter.getSystemId();
if (systemId != null) {
predicates.add(builder.equal(root.get(SysProvisioningArchive_.system).get(SysSystem_.id), systemId));
}
// From
ZonedDateTime from = filter.getFrom();
if (from != null) {
predicates.add(builder.greaterThanOrEqualTo(root.get(SysProvisioningArchive_.created), from));
}
// Till
ZonedDateTime till = filter.getTill();
if (till != null) {
predicates.add(builder.lessThanOrEqualTo(root.get(SysProvisioningArchive_.created), till));
}
// Operation type
ProvisioningEventType operationType = filter.getOperationType();
if (operationType != null) {
predicates.add(builder.equal(root.get(SysProvisioningArchive_.operationType), operationType));
}
// Entity type
SystemEntityType entityType = filter.getEntityType();
if (entityType != null) {
predicates.add(builder.equal(root.get(SysProvisioningArchive_.entityType), entityType));
}
// Entity identifier
UUID entityIdentifier = filter.getEntityIdentifier();
if (entityIdentifier != null) {
predicates.add(builder.equal(root.get(SysProvisioningArchive_.entityIdentifier), entityIdentifier));
}
// System entity
if (filter.getSystemEntity() != null) {
throw new ResultCodeException(CoreResultCode.BAD_FILTER, "Filter by system entity identifier is not supported. Use system entity uid filter.");
}
// System entity UID
String systemEntityUid = filter.getSystemEntityUid();
if (StringUtils.isNotEmpty(systemEntityUid)) {
predicates.add(builder.equal(root.get(SysProvisioningArchive_.systemEntityUid), systemEntityUid));
}
// Operation result and his state
OperationState resultState = filter.getResultState();
if (resultState != null) {
predicates.add(builder.equal(root.get(SysProvisioningArchive_.result).get(OperationResultDto.PROPERTY_STATE), resultState));
}
// Batch id
if (filter.getBatchId() != null) {
throw new UnsupportedOperationException("Filter by batch identifier is not supported in archive.");
}
// Role-request ID
UUID roleRequestId = filter.getRoleRequestId();
if (roleRequestId != null) {
predicates.add(builder.equal(root.get(SysProvisioningArchive_.roleRequestId), roleRequestId));
}
// updated attributes
List<String> attributeUpdated = filter.getAttributeUpdated();
if (!CollectionUtils.isEmpty(attributeUpdated)) {
Subquery<SysProvisioningAttribute> subquery = query.subquery(SysProvisioningAttribute.class);
Root<SysProvisioningAttribute> subRoot = subquery.from(SysProvisioningAttribute.class);
subquery.select(subRoot);
subquery.where(builder.and(// correlation attr
builder.equal(subRoot.get(SysProvisioningAttribute_.provisioningId), root.get(SysProvisioningArchive_.id)), subRoot.get(SysProvisioningAttribute_.name).in(attributeUpdated), builder.isFalse(subRoot.get(SysProvisioningAttribute_.removed))));
predicates.add(builder.exists(subquery));
}
// removed attributes
List<String> attributeRemoved = filter.getAttributeRemoved();
if (!CollectionUtils.isEmpty(attributeRemoved)) {
Subquery<SysProvisioningAttribute> subquery = query.subquery(SysProvisioningAttribute.class);
Root<SysProvisioningAttribute> subRoot = subquery.from(SysProvisioningAttribute.class);
subquery.select(subRoot);
subquery.where(builder.and(// correlation attr
builder.equal(subRoot.get(SysProvisioningAttribute_.provisioningId), root.get(SysProvisioningArchive_.id)), subRoot.get(SysProvisioningAttribute_.name).in(attributeRemoved), builder.isTrue(subRoot.get(SysProvisioningAttribute_.removed))));
predicates.add(builder.exists(subquery));
}
// empty provisioning
Boolean emptyProvisioning = filter.getEmptyProvisioning();
if (emptyProvisioning != null) {
Subquery<SysProvisioningAttribute> subquery = query.subquery(SysProvisioningAttribute.class);
Root<SysProvisioningAttribute> subRoot = subquery.from(SysProvisioningAttribute.class);
subquery.select(subRoot);
subquery.where(// correlation attr)
builder.and(builder.equal(subRoot.get(SysProvisioningAttribute_.provisioningId), root.get(SysProvisioningArchive_.id))));
//
// has attributes
Predicate provisioningPredicate = builder.exists(subquery);
if (emptyProvisioning) {
provisioningPredicate = builder.and(// empty
builder.not(provisioningPredicate), // delete operations are not considered as empty
builder.notEqual(root.get(SysProvisioningArchive_.operationType), ProvisioningEventType.DELETE));
} else {
// delete operations are not considered as empty or filled => show all time
provisioningPredicate = builder.or(provisioningPredicate, builder.equal(root.get(SysProvisioningArchive_.operationType), ProvisioningEventType.DELETE));
}
predicates.add(provisioningPredicate);
}
if (filter.getEmptyProvisioningType() != null) {
throw new UnsupportedOperationException("Filter by empty provisioning type is not supported in archive. Use 'emptyProvisioning' parameter instead.");
}
//
return predicates;
}
Aggregations