Search in sources :

Example 1 with SysBlockedOperationDto

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);
}
Also used : SysConnectorKeyDto(eu.bcvsolutions.idm.acc.dto.SysConnectorKeyDto) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) SysBlockedOperationDto(eu.bcvsolutions.idm.acc.dto.SysBlockedOperationDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysConnectorServerDto(eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 2 with SysBlockedOperationDto

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());
}
Also used : SysProvisioningBatchDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto) SysBlockedOperationDto(eu.bcvsolutions.idm.acc.dto.SysBlockedOperationDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 3 with SysBlockedOperationDto

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);
}
Also used : SysProvisioningBatchDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto) SysBlockedOperationDto(eu.bcvsolutions.idm.acc.dto.SysBlockedOperationDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

SysBlockedOperationDto (eu.bcvsolutions.idm.acc.dto.SysBlockedOperationDto)3 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)3 SysProvisioningBatchDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto)2 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)2 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)2 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)2 Test (org.junit.Test)2 SysConnectorKeyDto (eu.bcvsolutions.idm.acc.dto.SysConnectorKeyDto)1 SysConnectorServerDto (eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto)1 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)1 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)1 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)1