use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemEntityServiceFilterTest method createEntitySystem.
/**
* Create {@link SysSystemEntityDto}
* @param uid
* @param type
* @param systemId
* @param id
* @return
*/
private SysSystemEntityDto createEntitySystem(String uid, SystemEntityType type, UUID systemId, UUID id) {
SysSystemEntityDto entity = new SysSystemEntityDto();
entity.setUid(uid);
entity.setEntityType(type);
entity.setSystem(systemId);
entity.setId(id);
entityService.save(entity);
return entity;
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemEntityServiceFilterTest method testUid.
@Test
public void testUid() {
SysSystemDto system = helper.createTestResourceSystem(false);
SysSystemEntityDto entity1 = createEntitySystem("test1-" + System.currentTimeMillis(), SystemEntityType.CONTRACT, system.getId(), UUID.randomUUID());
createEntitySystem("test2-" + System.currentTimeMillis(), SystemEntityType.CONTRACT, system.getId(), UUID.randomUUID());
createEntitySystem("test3-" + System.currentTimeMillis(), SystemEntityType.CONTRACT, system.getId(), UUID.randomUUID());
//
SysSystemEntityFilter testFilter = new SysSystemEntityFilter();
testFilter.setUid(entity1.getUid());
Page<SysSystemEntityDto> pages = entityService.find(testFilter, null);
assertEquals(1, pages.getTotalElements());
assertEquals(entity1.getId(), pages.getContent().get(0).getId());
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class SysProvisioningOperationFilterIntegrationTest method createProvisioningOperation.
private SysProvisioningOperationDto createProvisioningOperation(SystemEntityType type, SysSystemDto system) {
SysProvisioningOperationDto provisioningOperation = new SysProvisioningOperationDto();
provisioningOperation.setEntityType(type);
provisioningOperation.setOperationType(ProvisioningEventType.CREATE);
provisioningOperation.setProvisioningContext(new ProvisioningContext());
provisioningOperation.setSystem(system.getId());
provisioningOperation.setEntityIdentifier(UUID.randomUUID());
SysSystemEntityDto systemEntity = ((TestHelper) getHelper()).createSystemEntity(system);
provisioningOperation.setSystemEntity(systemEntity.getId());
OperationResult result = new OperationResult();
result.setState(OperationState.RUNNING);
provisioningOperation.setResult(result);
return operationService.save(provisioningOperation);
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class AbstractProvisioningProcessor method process.
/**
* Prepare provisioning operation execution
*/
@Override
public EventResult<SysProvisioningOperationDto> process(EntityEvent<SysProvisioningOperationDto> event) {
SysProvisioningOperationDto provisioningOperation = event.getContent();
SysSystemDto system = systemService.get(provisioningOperation.getSystem());
IcConnectorObject connectorObject = provisioningOperation.getProvisioningContext().getConnectorObject();
IcObjectClass objectClass = connectorObject.getObjectClass();
SysSystemEntityDto systemEntity = systemEntityService.getByProvisioningOperation(provisioningOperation);
// If exists password in attributes and system support password filter set also echo
boolean processEcho = false;
List<UUID> accountIds = null;
LOG.debug("Start provisioning operation [{}] for object with uid [{}] and connector object [{}]", provisioningOperation.getOperationType(), systemEntity.getUid(), 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()));
}
// Load connector configuration from connectorType.
ConnectorType connectorType = connectorManager.findConnectorTypeBySystem(system);
IcConnectorConfiguration connectorConfig = connectorType.getConnectorConfiguration(system);
//
try {
provisioningOperation = provisioningOperationService.saveOperation(provisioningOperation);
// convert confidential string to guarded strings before provisioning realization
connectorObject = provisioningOperationService.getFullConnectorObject(provisioningOperation);
provisioningOperation.getProvisioningContext().setConnectorObject(connectorObject);
for (IcAttribute attribute : connectorObject.getAttributes()) {
if (attribute.getName().equals(ProvisioningService.PASSWORD_SCHEMA_PROPERTY_NAME) && attribute instanceof IcPasswordAttribute) {
if (this.hasSystemPasswordFilter(system)) {
IcPasswordAttributeImpl password = ((IcPasswordAttributeImpl) attribute);
accountIds = getAccounts(system.getId(), systemEntity.getId());
for (UUID accountId : accountIds) {
passwordFilterManager.setEchoForChange(accountId, password.getPasswordValue());
}
processEcho = true;
}
break;
}
}
//
IcUidAttribute resultUid = processInternal(provisioningOperation, connectorConfig);
// update system entity, when identifier on target system differs
if (resultUid != null && resultUid.getUidValue() != null) {
if (!systemEntity.getUid().equals(resultUid.getUidValue()) || systemEntity.isWish()) {
systemEntity.setUid(resultUid.getUidValue());
systemEntity.setWish(false);
systemEntity = systemEntityService.save(systemEntity);
LOG.info("UID was changed. System entity with uid [{}] was updated", systemEntity.getUid());
}
} else {
// e.g. update doesn't return
if (systemEntity.isWish()) {
systemEntity.setWish(false);
systemEntity = systemEntityService.save(systemEntity);
LOG.info("UID was changed. System entity with uid [{}] was updated", systemEntity.getUid());
}
}
provisioningOperation = provisioningOperationService.handleSuccessful(provisioningOperation);
} catch (Exception ex) {
provisioningOperation = provisioningOperationService.handleFailed(provisioningOperation, ex);
if (processEcho) {
// Clear echo record about password change
accountIds.forEach(accountId -> {
passwordFilterManager.clearChangedEcho(accountId);
});
}
}
// set operation back to content
event.setContent(provisioningOperation);
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class ProvisioningBreakProcessor method process.
@Override
public EventResult<SysProvisioningOperationDto> process(EntityEvent<SysProvisioningOperationDto> event) {
SysProvisioningOperationDto provisioningOperation = event.getContent();
ProvisioningEventType operationType = provisioningOperation.getOperationType();
SysSystemDto system = systemService.get(provisioningOperation.getSystem());
try {
// system may be blocked
boolean blocked = isSystemBlockedOperation(operationType, system);
//
if (blocked) {
// system is already blocked
provisioningOperation = blockOperation(provisioningOperation, system);
event.setContent(provisioningOperation);
return new DefaultEventResult<>(event, this, blocked);
}
//
// try found provisioning break configuration
SysProvisioningBreakConfigDto breakConfig = breakConfigService.getConfig(operationType, system.getId());
if (breakConfig == null) {
LOG.debug("Provisioning break configuration for system name: [{}] and operation: [{}] not found. Global configuration will be used.", system.getCode(), operationType.toString());
breakConfig = breakConfigService.getGlobalBreakConfiguration(operationType);
}
//
if (breakConfig == null) {
LOG.debug("Global configuration for provisioning break isn't found.");
return new DefaultEventResult<>(event, this, blocked);
}
//
if (breakConfig.isDisabled()) {
LOG.debug("Provisioning break configuration id: [{}] for system name: [{}] and operation: [{}] is disabled.", breakConfig.getId(), system.getCode(), operationType.toString());
// break configuration is disable continue
return new DefaultEventResult<>(event, this, blocked);
}
// Process provisioning break in synchronized method
blocked = processProvisioningBreak(provisioningOperation, operationType, system, breakConfig);
event.setContent(provisioningOperation);
return new DefaultEventResult<>(event, this, blocked);
} catch (Exception ex) {
SysSystemEntityDto systemEntityDto = provisioningOperationService.getByProvisioningOperation(provisioningOperation);
LOG.error("Unexpect error while evaluate provisioning break.", ex);
throw new ProvisioningException(AccResultCode.PROVISIONING_FAILED, ImmutableMap.of("name", systemEntityDto.getUid(), "system", system.getName(), "operationType", operationType, "objectClass", provisioningOperation.getProvisioningContext().getConnectorObject().getObjectClass().getType()), ex);
}
}
Aggregations