use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class DefaultAccTestHelper method createSystemEntity.
@Override
public SysSystemEntityDto createSystemEntity(SysSystemDto system) {
SysSystemEntityDto systemEntity = new SysSystemEntityDto(createName(), SystemEntityType.IDENTITY);
systemEntity.setSystem(system.getId());
systemEntity.setWish(true);
return systemEntityService.save(systemEntity);
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class RoleSynchronizationExecutor method assignMissingIdentityRoles.
/**
* Assign missing identity roles.
*/
private void assignMissingIdentityRoles(IdmRoleDto roleDto, SysSyncRoleConfigDto config, SysSyncItemLogDto logItem, List<IdmIdentityRoleDto> existsIdentityRoleDtos, Set<UUID> membersContractIds, SysSystemDto userSystemDto, int[] count, String uid, SynchronizationContext context) {
// On every 20th item will be hibernate flushed and check if sync was not ended.
if (count[0] % 20 == 0 && count[0] > 0) {
if (!checkForCancelAndFlush(config)) {
return;
}
}
count[0]++;
// Need to find account using SysSystemEntityDto uid, because uid of AccAccountDto can be different.
SysSystemEntityFilter entityFilter = new SysSystemEntityFilter();
entityFilter.setEntityType(SystemEntityType.IDENTITY);
entityFilter.setSystemId(userSystemDto.getId());
entityFilter.setUid(uid);
SysSystemEntityDto systemEntity = systemEntityService.find(entityFilter, null).stream().findFirst().orElse(null);
if (systemEntity == null) {
return;
}
AccAccountFilter accAccountFilter = new AccAccountFilter();
accAccountFilter.setSystemEntityId(systemEntity.getId());
final UUID accAccountId = accountService.findIds(accAccountFilter, null).stream().findFirst().orElse(null);
if (accAccountId == null) {
return;
}
AccIdentityAccountFilter identityAccountWithoutRelationFilter = new AccIdentityAccountFilter();
identityAccountWithoutRelationFilter.setAccountId(accAccountId);
AccIdentityAccountDto identityAccountDto = identityAccountService.find(identityAccountWithoutRelationFilter, null).getContent().stream().findFirst().orElse(null);
if (identityAccountDto == null) {
return;
}
UUID identityId = identityAccountDto.getIdentity();
IdmIdentityContractDto primeContract = identityContractService.getPrimeContract(identityId);
if (primeContract == null) {
addToItemLog(logItem, MessageFormat.format("!!Role was not assigned to the user [{0}], because primary contract was not found!!", uid));
initSyncActionLog(SynchronizationActionType.UPDATE_ENTITY, OperationResultType.WARNING, logItem, context.getLog(), context.getActionLogs());
return;
}
membersContractIds.add(primeContract.getId());
IdmIdentityRoleDto existIdentityRoleDto = existsIdentityRoleDtos.stream().filter(identityRole -> primeContract.getId().equals(identityRole.getIdentityContract())).findFirst().orElse(null);
if (existIdentityRoleDto != null) {
// Identity already has the role.
return;
}
addToItemLog(logItem, MessageFormat.format("Role is not assigned for user [{0}] and contract [{1}]. Role request for add role will be created.", uid, primeContract.getId()));
// Get cache with role-requests by identity-contract.
Map<UUID, UUID> roleRequestCache = getRoleRequestCache();
// Get role-request for the primary contract from a cache. If no request is present, then create one.
initRoleRequest(primeContract, roleRequestCache, config);
UUID roleRequestId = roleRequestCache.get(primeContract.getId());
IdmRoleRequestDto mockRoleRequest = new IdmRoleRequestDto();
mockRoleRequest.setId(roleRequestId);
// Create a concept for assign a role to primary contract.
roleRequestService.createConcept(mockRoleRequest, primeContract, null, roleDto.getId(), ConceptRoleRequestOperation.ADD);
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class IdentitySyncTest method testLinkIdentityRemoveWishSync.
// unlinked, system entity has "wish" => removed "wish"
@Test
public void testLinkIdentityRemoveWishSync() {
SysSystemDto system = initData();
Assert.assertNotNull(system);
SysSyncIdentityConfigDto config = doCreateSyncConfig(system);
// Create system entity with "wish"
createSystemEntityWish(system);
helper.createIdentity(IDENTITY_ONE);
helper.startSynchronization(config);
SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.LINK, 1, OperationResultType.SUCCESS);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
// System entity is no longer "wish"
SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, IDENTITY_ONE);
Assert.assertFalse(systemEntity.isWish());
// Delete log
syncLogService.delete(log);
syncConfigService.delete(config);
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class IdentitySyncTest method createSystemEntityWish.
private void createSystemEntityWish(SysSystemDto system) {
SysSystemEntityDto systemEntity = new SysSystemEntityDto();
systemEntity.setUid(IDENTITY_ONE);
systemEntity.setEntityType(SystemEntityType.IDENTITY);
systemEntity.setWish(true);
systemEntity.setSystem(system.getId());
systemEntity = systemEntityService.save(systemEntity);
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class PrepareConnectorObjectProcessor method process.
/**
* Prepare provisioning operation execution
*/
@Override
public EventResult<SysProvisioningOperationDto> process(EntityEvent<SysProvisioningOperationDto> event) {
SysProvisioningOperationDto provisioningOperation = event.getContent();
SysSystemDto system = systemService.get(provisioningOperation.getSystem());
IcObjectClass objectClass = provisioningOperation.getProvisioningContext().getConnectorObject().getObjectClass();
SysSystemEntityDto systemEntity = provisioningOperationService.getByProvisioningOperation(provisioningOperation);
String uid = systemEntity.getUid();
boolean isWish = systemEntity.isWish();
LOG.debug("Start preparing attribubes for provisioning operation [{}] for object with uid [{}] and connector object [{}]", provisioningOperation.getOperationType(), uid, objectClass.getType());
// Find connector identification persisted in system
if (system.getConnectorKey() == null) {
throw new ProvisioningException(AccResultCode.CONNECTOR_KEY_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
}
try {
IcConnectorObject existsConnectorObject = null;
// We do not want search account on the target system, when this is the first
// call the connector and auto mapping is not allowed.
ConnectorType connectorType = connectorManager.findConnectorTypeBySystem(system);
if (!isWish || provisioningConfiguration.isAllowedAutoMappingOnExistingAccount()) {
existsConnectorObject = connectorType.readConnectorObject(system, uid, objectClass);
}
if (existsConnectorObject == null) {
processCreate(provisioningOperation);
} else {
processUpdate(provisioningOperation, existsConnectorObject, connectorType);
// prepare attributes on target system for FE view
ProvisioningContext context = provisioningOperation.getProvisioningContext();
IcConnectorObject systemAttrs = intersectAccountAndSystemAttrs(context.getAccountObject(), existsConnectorObject);
context.setSystemConnectorObject(systemAttrs);
if (!provisioningOperation.isDryRun()) {
provisioningOperation = provisioningOperationService.saveOperation(provisioningOperation);
}
}
//
LOG.debug("Preparing attribubes for provisioning operation [{}] for object with uid [{}] and connector object [{}] is sucessfully completed", provisioningOperation.getOperationType(), uid, objectClass.getType());
if (!provisioningOperation.isDryRun()) {
// set back to event content
provisioningOperation = provisioningOperationService.saveOperation(provisioningOperation);
// log attributes used in provisioning context into provisioning attributes
provisioningAttributeService.saveAttributes(provisioningOperation);
}
event.setContent(provisioningOperation);
return new DefaultEventResult<>(event, this);
} catch (Exception ex) {
if (!provisioningOperation.isDryRun()) {
provisioningOperation = provisioningOperationService.handleFailed(provisioningOperation, ex);
}
// TODO nastavit vyjimku stav do provisioning operation podobne jak se deje v handleFailed
event.setContent(provisioningOperation);
return new DefaultEventResult<>(event, this, true);
}
}
Aggregations