use of eu.bcvsolutions.idm.acc.dto.SysBlockedOperationDto in project CzechIdMng by bcvsolutions.
the class SystemSaveProcessor method process.
@Override
public EventResult<SysSystemDto> process(EntityEvent<SysSystemDto> event) {
SysSystemDto dto = event.getContent();
// create default connector server
if (dto.getConnectorServer() == null) {
dto.setConnectorServer(new SysConnectorServerDto());
}
// create default connector key
if (dto.getConnectorKey() == null) {
dto.setConnectorKey(new SysConnectorKeyDto());
}
// create default blocked operations
if (dto.getBlockedOperation() == null) {
dto.setBlockedOperation(new SysBlockedOperationDto());
}
if (!service.isNew(dto)) {
// Check if is connector changed
SysSystemDto oldSystem = service.get(dto.getId());
if (!dto.getConnectorKey().equals(oldSystem.getConnectorKey())) {
// If is connector changed, we set virtual to false. (Virtual
// connectors set this attribute on true by themselves)
dto.setVirtual(false);
}
// check blocked provisioning operation and clear provisioning break cache
clearProvisionignBreakCache(dto, oldSystem);
}
SysSystemDto newSystem = service.saveInternal(dto);
event.setContent(newSystem);
// save password from remote connector server to confidential storage
if (dto.getConnectorServer().getPassword() != null) {
// save for newSystem
confidentialStorage.save(newSystem.getId(), SysSystem.class, SysSystemService.REMOTE_SERVER_PASSWORD, dto.getConnectorServer().getPassword().asString());
//
// set asterix
newSystem.getConnectorServer().setPassword(new GuardedString(GuardedString.SECRED_PROXY_STRING));
}
// TODO: clone content - mutable previous event content :/
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.acc.dto.SysBlockedOperationDto in project CzechIdMng by bcvsolutions.
the class ProvisioningBreakProcessorTest method testBlockSystemCreate.
@Test
public void testBlockSystemCreate() {
SysSystemDto system = testHelper.createTestResourceSystem(true);
SysBlockedOperationDto blockedOperationDto = new SysBlockedOperationDto();
blockedOperationDto.blockCreate();
system.setBlockedOperation(blockedOperationDto);
system = systemService.save(system);
//
IdmIdentityDto identity = testHelper.createIdentity();
createProvisioningBreak(20l, 3, 2, ProvisioningEventType.CREATE, system.getId());
//
this.createAccount(system, identity);
//
// create block
provisioningService.doProvisioning(identity);
SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, identity.getUsername());
//
SysProvisioningBatchDto batch = batchService.findBatch(system.getId(), identity.getId(), systemEntity.getId());
//
List<SysProvisioningOperationDto> content = provisioningOperationService.findByBatchId(batch.getId(), null).getContent();
assertEquals(1, content.size());
SysProvisioningOperationDto sysProvisioningOperationDto = content.get(0);
//
assertEquals(ProvisioningEventType.CREATE, sysProvisioningOperationDto.getOperationType());
assertEquals(OperationState.BLOCKED, sysProvisioningOperationDto.getResult().getState());
}
use of eu.bcvsolutions.idm.acc.dto.SysBlockedOperationDto in project CzechIdMng by bcvsolutions.
the class ProvisioningBreakProcessorTest method testClearCache.
@Test
public void testClearCache() {
SysSystemDto system = testHelper.createTestResourceSystem(true);
IdmIdentityDto identity = testHelper.createIdentity();
createProvisioningBreak(20l, 3, null, ProvisioningEventType.UPDATE, system.getId());
//
this.createAccount(system, identity);
//
//
// create
provisioningService.doProvisioning(identity);
provisioningService.doProvisioning(identity);
provisioningService.doProvisioning(identity);
//
SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, identity.getUsername());
SysProvisioningBatchDto batch = batchService.findBatch(system.getId(), identity.getId(), systemEntity.getId());
//
assertNull(batch);
//
SysBlockedOperationDto blockedOperation = new SysBlockedOperationDto();
blockedOperation.blockUpdate();
system.setBlockedOperation(blockedOperation);
// block system
system = systemService.save(system);
//
blockedOperation = new SysBlockedOperationDto();
blockedOperation.setUpdateOperation(Boolean.FALSE);
system.setBlockedOperation(blockedOperation);
// unblock system, clear cache
system = systemService.save(system);
//
provisioningService.doProvisioning(identity);
provisioningService.doProvisioning(identity);
//
systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, identity.getUsername());
batch = batchService.findBatch(system.getId(), identity.getId(), systemEntity.getId());
//
assertNull(batch);
}
Aggregations