Search in sources :

Example 31 with SysSystemDto

use of eu.bcvsolutions.idm.acc.dto.SysSystemDto in project CzechIdMng by bcvsolutions.

the class PrepareConnectorObjectProcessor method processUpdate.

@SuppressWarnings("unchecked")
private void processUpdate(SysProvisioningOperationDto provisioningOperation, IcConnectorConfiguration connectorConfig, IcConnectorObject existsConnectorObject) {
    SysSystemDto system = systemService.get(provisioningOperation.getSystem());
    String systemEntityUid = provisioningOperationService.getByProvisioningOperation(provisioningOperation).getUid();
    ProvisioningContext provisioningContext = provisioningOperation.getProvisioningContext();
    IcConnectorObject connectorObject = provisioningContext.getConnectorObject();
    IcObjectClass objectClass = connectorObject.getObjectClass();
    // 
    IcConnectorObject updateConnectorObject;
    if (provisioningContext.getAccountObject() == null) {
        updateConnectorObject = connectorObject;
    } else {
        Map<ProvisioningAttributeDto, Object> fullAccountObject = provisioningOperationService.getFullAccountObject(provisioningOperation);
        updateConnectorObject = new IcConnectorObjectImpl(systemEntityUid, objectClass, null);
        SysSystemMappingDto mapping = getMapping(system, provisioningOperation.getEntityType());
        SysSchemaObjectClassDto schemaObjectClassDto = schemaObjectClassService.get(mapping.getObjectClass());
        List<SysSchemaAttributeDto> schemaAttributes = findSchemaAttributes(system, schemaObjectClassDto);
        SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
        filter.setEntityIdentifier(provisioningOperation.getEntityIdentifier());
        filter.setEntityType(provisioningOperation.getEntityType());
        filter.setResultState(OperationState.EXECUTED);
        SysProvisioningArchiveDto lastSuccessEntity = null;
        for (Entry<ProvisioningAttributeDto, Object> entry : fullAccountObject.entrySet()) {
            ProvisioningAttributeDto provisioningAttribute = entry.getKey();
            Optional<SysSchemaAttributeDto> schemaAttributeOptional = schemaAttributes.stream().filter(schemaAttribute -> {
                return provisioningAttribute.getSchemaAttributeName().equals(schemaAttribute.getName());
            }).findFirst();
            if (!schemaAttributeOptional.isPresent()) {
                throw new ProvisioningException(AccResultCode.PROVISIONING_SCHEMA_ATTRIBUTE_IS_FOUND, ImmutableMap.of("attribute", provisioningAttribute.getSchemaAttributeName()));
            }
            SysSchemaAttributeDto schemaAttribute = schemaAttributeOptional.get();
            if (schemaAttribute.isUpdateable()) {
                if (schemaAttribute.isReturnedByDefault()) {
                    Object idmValue = fullAccountObject.get(provisioningAttribute);
                    IcAttribute attribute = existsConnectorObject.getAttributeByName(schemaAttribute.getName());
                    Object connectorValue = attribute != null ? (attribute.isMultiValue() ? attribute.getValues() : attribute.getValue()) : null;
                    Object resultValue = idmValue;
                    if (AttributeMappingStrategyType.CREATE == provisioningAttribute.getStrategyType()) {
                        // We do update, attributes with create strategy will be skipped
                        continue;
                    }
                    if (provisioningAttribute.isSendOnlyIfNotNull()) {
                        if (this.isValueEmpty(idmValue)) {
                            // Skip this attribute (marked with flag sendOnlyIfNotNull), because idm value is null
                            continue;
                        }
                    }
                    if (AttributeMappingStrategyType.WRITE_IF_NULL == provisioningAttribute.getStrategyType()) {
                        boolean existSetAttribute = fullAccountObject.keySet().stream().filter(provisioningAttributeKey -> {
                            return provisioningAttributeKey.getSchemaAttributeName().equals(schemaAttribute.getName()) && AttributeMappingStrategyType.SET == provisioningAttributeKey.getStrategyType();
                        }).findFirst().isPresent();
                        boolean existMergeAttribute = fullAccountObject.keySet().stream().filter(provisioningAttributeKey -> {
                            return provisioningAttributeKey.getSchemaAttributeName().equals(schemaAttribute.getName()) && AttributeMappingStrategyType.MERGE == provisioningAttributeKey.getStrategyType();
                        }).findFirst().isPresent();
                        boolean existAuthMergeAttribute = fullAccountObject.keySet().stream().filter(provisioningAttributeKey -> {
                            return provisioningAttributeKey.getSchemaAttributeName().equals(schemaAttribute.getName()) && AttributeMappingStrategyType.AUTHORITATIVE_MERGE == provisioningAttributeKey.getStrategyType();
                        }).findFirst().isPresent();
                        if (AttributeMappingStrategyType.WRITE_IF_NULL == provisioningAttribute.getStrategyType()) {
                            List<IcAttribute> icAttributes = existsConnectorObject.getAttributes();
                            // 
                            Optional<IcAttribute> icAttributeOptional = icAttributes.stream().filter(ica -> {
                                return schemaAttribute.getName().equals(ica.getName());
                            }).findFirst();
                            IcAttribute icAttribute = null;
                            if (icAttributeOptional.isPresent()) {
                                icAttribute = icAttributeOptional.get();
                            }
                            // We need do transform from resource first
                            Object transformedConnectorValue = this.transformValueFromResource(provisioningAttribute.getTransformValueFromResourceScript(), schemaAttribute, icAttribute, icAttributes, system);
                            if (transformedConnectorValue != null || existSetAttribute || existAuthMergeAttribute || existMergeAttribute) {
                                // or exists same attribute with  SET/MERGE/AUTH_MERGE strategy (this strategies has higher priority)
                                continue;
                            }
                        }
                    }
                    if (AttributeMappingStrategyType.MERGE == provisioningAttribute.getStrategyType()) {
                        // Load last provisioning history
                        if (lastSuccessEntity == null) {
                            List<SysProvisioningArchiveDto> lastSuccessEntities = provisioningArchiveService.find(filter, new PageRequest(0, 1, new Sort(Direction.DESC, MODIFIED_FIELD_NAME))).getContent();
                            if (!lastSuccessEntities.isEmpty()) {
                                lastSuccessEntity = lastSuccessEntities.get(0);
                            }
                        }
                        // Merge IdM values with connector values
                        if (connectorValue instanceof List) {
                            List<Object> connectorValues = new ArrayList<>((List<Object>) connectorValue);
                            List<Object> idmValues = null;
                            if (idmValue instanceof List) {
                                idmValues = (List<Object>) idmValue;
                            }
                            if (idmValues != null) {
                                idmValues.stream().forEach(value -> {
                                    if (!connectorValues.contains(value)) {
                                        connectorValues.add(value);
                                    }
                                });
                            }
                            resultValue = connectorValues;
                        }
                        // Delete missing values by last provisioning history
                        if (lastSuccessEntity != null && lastSuccessEntity.getProvisioningContext() != null && lastSuccessEntity.getProvisioningContext().getAccountObject() != null && lastSuccessEntity.getProvisioningContext().getAccountObject().containsKey(provisioningAttribute)) {
                            Object oldValue = lastSuccessEntity.getProvisioningContext().getAccountObject().get(provisioningAttribute);
                            if (oldValue instanceof List) {
                                if (!oldValue.equals(idmValue)) {
                                    // Search all deleted values (managed by IdM) by founded last provisioning values
                                    List<?> deletedValues = ((List<?>) oldValue).stream().filter(value -> {
                                        List<?> idmValues = null;
                                        if (idmValue instanceof List) {
                                            idmValues = (List<?>) idmValue;
                                        }
                                        if (idmValues != null && idmValues.contains(value)) {
                                            return false;
                                        }
                                        return true;
                                    }).collect(Collectors.toList());
                                    if (resultValue instanceof List) {
                                        List<?> resultValues = new ArrayList<>((List<Object>) resultValue);
                                        // Remove all deleted values (managed by IdM)
                                        resultValues.removeAll(deletedValues);
                                        resultValue = resultValues;
                                    }
                                }
                            }
                        }
                    }
                    // Update attribute on resource by given mapping
                    // attribute and mapped value in entity
                    IcAttribute updatedAttribute = updateAttribute(systemEntityUid, resultValue, schemaAttribute, existsConnectorObject, system, provisioningAttribute);
                    if (updatedAttribute != null) {
                        updateConnectorObject.getAttributes().add(updatedAttribute);
                    }
                } else {
                    // filled values only
                    if (fullAccountObject.get(provisioningAttribute) != null) {
                        IcAttribute createdAttribute = createAttribute(schemaAttribute, fullAccountObject.get(provisioningAttribute));
                        if (createdAttribute != null) {
                            updateConnectorObject.getAttributes().add(createdAttribute);
                        }
                    }
                }
            }
        }
    }
    // 
    provisioningOperation.getProvisioningContext().setConnectorObject(updateConnectorObject);
    provisioningOperation.setOperationType(ProvisioningEventType.UPDATE);
}
Also used : SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) NotificationManager(eu.bcvsolutions.idm.core.notification.api.service.NotificationManager) Autowired(org.springframework.beans.factory.annotation.Autowired) Enabled(eu.bcvsolutions.idm.core.security.api.domain.Enabled) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) SysSchemaAttribute(eu.bcvsolutions.idm.acc.entity.SysSchemaAttribute) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) Map(java.util.Map) ProvisioningConfiguration(eu.bcvsolutions.idm.acc.config.domain.ProvisioningConfiguration) Sort(org.springframework.data.domain.Sort) AbstractEntityEventProcessor(eu.bcvsolutions.idm.core.api.event.AbstractEntityEventProcessor) ImmutableMap(com.google.common.collect.ImmutableMap) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) Collection(java.util.Collection) SysProvisioningOperationService(eu.bcvsolutions.idm.acc.service.api.SysProvisioningOperationService) SystemOperationType(eu.bcvsolutions.idm.acc.domain.SystemOperationType) PageRequest(org.springframework.data.domain.PageRequest) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) List(java.util.List) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) CollectionUtils(org.springframework.util.CollectionUtils) Entry(java.util.Map.Entry) Optional(java.util.Optional) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute) SysSchemaObjectClassService(eu.bcvsolutions.idm.acc.service.api.SysSchemaObjectClassService) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) AccResultCode(eu.bcvsolutions.idm.acc.domain.AccResultCode) IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) AttributeMappingStrategyType(eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType) ProvisioningEventType(eu.bcvsolutions.idm.acc.domain.ProvisioningEventType) SysSystemEntityService(eu.bcvsolutions.idm.acc.service.api.SysSystemEntityService) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) Strings(com.google.common.base.Strings) SysSystemMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemMappingService) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) IcUidAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcUidAttributeImpl) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) EventResult(eu.bcvsolutions.idm.core.api.event.EventResult) Direction(org.springframework.data.domain.Sort.Direction) EntityEvent(eu.bcvsolutions.idm.core.api.event.EntityEvent) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) Description(org.springframework.context.annotation.Description) AccModuleDescriptor(eu.bcvsolutions.idm.acc.AccModuleDescriptor) SysProvisioningArchiveService(eu.bcvsolutions.idm.acc.service.api.SysProvisioningArchiveService) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) SysSchemaAttributeService(eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService) Component(org.springframework.stereotype.Component) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) SysSystemAttributeMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService) ResultModel(eu.bcvsolutions.idm.core.api.dto.ResultModel) Assert(org.springframework.util.Assert) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) ArrayList(java.util.ArrayList) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) PageRequest(org.springframework.data.domain.PageRequest) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) Sort(org.springframework.data.domain.Sort) List(java.util.List) ArrayList(java.util.ArrayList) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl)

Example 32 with SysSystemDto

use of eu.bcvsolutions.idm.acc.dto.SysSystemDto in project CzechIdMng by bcvsolutions.

the class ProvisioningBreakProcessor method process.

@Override
public EventResult<SysProvisioningOperationDto> process(EntityEvent<SysProvisioningOperationDto> event) {
    try {
        SysProvisioningOperationDto provisioningOperation = event.getContent();
        ProvisioningEventType operationType = provisioningOperation.getOperationType();
        SysSystemDto system = systemService.get(provisioningOperation.getSystem());
        // 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);
        }
        Long currentTimeMillis = System.currentTimeMillis();
        // 
        // get cache for system
        SysProvisioningBreakItems cache = breakConfigService.getCacheProcessedItems(system.getId());
        // calculate timestamp without period
        Long timestampWithoutPeriod = currentTimeMillis - breakConfig.getPeriod(TimeUnit.MILLISECONDS);
        // remove older records
        cache.removeOlderRecordsThan(operationType, timestampWithoutPeriod);
        // get actual count - processed items from timestampWithoutPeriod
        int actualCount = cache.getSizeRecordsNewerThan(operationType, timestampWithoutPeriod);
        // operation count is sum all previous operation except this operation
        if (breakConfig.getWarningLimit() != null && breakConfig.getWarningLimit().equals(actualCount)) {
            // disabled may be null
            if (breakConfig.getDisableLimit() == null) {
                LOG.warn("Block for the system id [{}] and operation [{}] is not set. Operation counter [{}].", provisioningOperation.getSystem(), provisioningOperation.getOperationType().toString(), actualCount);
            } else {
                LOG.warn("To block the system id [{}] for operation [{}] remains [{}] operations + send message.", provisioningOperation.getSystem(), provisioningOperation.getOperationType().toString(), breakConfig.getDisableLimit() - actualCount);
            }
            IdmNotificationTemplateDto template = null;
            if (breakConfig.getWarningTemplate() == null) {
                LOG.debug("Warning template for provisioning break id [{}] missing.", breakConfig.getId());
            } else {
                template = DtoUtils.getEmbedded(breakConfig, SysProvisioningBreakConfig_.warningTemplate, IdmNotificationTemplateDto.class);
            }
            // 
            sendMessage(AccModuleDescriptor.TOPIC_PROVISIONING_BREAK_WARNING, system, actualCount, template, breakConfig, operationType, cache.getDiffBetweenActualAndLast(operationType, currentTimeMillis));
        } else if (breakConfig.getDisableLimit() != null && actualCount >= breakConfig.getDisableLimit()) {
            // check count is higher than disable limit
            // block system for operation
            blockSystemForOperation(operationType, system);
            // 
            IdmNotificationTemplateDto template = null;
            if (breakConfig.getWarningTemplate() == null) {
                LOG.debug("Warning template for provisioning break id [{}] missing.", breakConfig.getId());
            } else {
                template = DtoUtils.getEmbedded(breakConfig, SysProvisioningBreakConfig_.disableTemplate, IdmNotificationTemplateDto.class);
            }
            // 
            sendMessage(AccModuleDescriptor.TOPIC_PROVISIONING_BREAK_DISABLE, system, actualCount, template, breakConfig, operationType, cache.getDiffBetweenActualAndLast(operationType, currentTimeMillis));
            // 
            LOG.warn("System id: [{}] will be blocked for operation: [{}].", provisioningOperation.getSystem(), operationType.toString());
            provisioningOperation = blockOperation(provisioningOperation, system);
            blocked = true;
        } else if (breakConfig.getWarningLimit() != null && actualCount > breakConfig.getWarningLimit()) {
            // after overrun warning limit, isn't send any another notification - add at least log
            if (breakConfig.getDisableLimit() == null) {
                LOG.warn("Block for the system id [{}] and operation [{}] is not set. Operation counter [{}].", provisioningOperation.getSystem(), provisioningOperation.getOperationType().toString(), actualCount);
            } else {
                LOG.warn("To block the system id [{}] for operation [{}] remains [{}] operations.", provisioningOperation.getSystem(), provisioningOperation.getOperationType().toString(), breakConfig.getDisableLimit() - actualCount);
            }
        }
        // remove all unless items in cache
        cache.addItem(operationType, currentTimeMillis);
        breakConfigService.saveCacheProcessedItems(provisioningOperation.getSystem(), cache);
        // 
        event.setContent(provisioningOperation);
        return new DefaultEventResult<>(event, this, blocked);
    } catch (Exception ex) {
        LOG.error("Unexpect error while evaluate provisioning break.", ex);
        throw new ProvisioningException(AccResultCode.PROVISIONING_FAILED, ex);
    }
}
Also used : ProvisioningEventType(eu.bcvsolutions.idm.acc.domain.ProvisioningEventType) SysProvisioningBreakConfigDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakConfigDto) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) SysProvisioningBreakItems(eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakItems) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException)

Example 33 with SysSystemDto

use of eu.bcvsolutions.idm.acc.dto.SysSystemDto in project CzechIdMng by bcvsolutions.

the class ProvisioningCreateProcessor method processInternal.

@Override
public IcUidAttribute processInternal(SysProvisioningOperationDto provisioningOperation, IcConnectorConfiguration connectorConfig) {
    // get system for password policy
    SysSystemDto system = systemService.get(provisioningOperation.getSystem());
    // execute provisioning
    IcConnectorObject connectorObject = provisioningOperation.getProvisioningContext().getConnectorObject();
    for (IcAttribute attribute : connectorObject.getAttributes()) {
        // if attribute is password and his value is empty, generate new password
        if (attribute instanceof IcPasswordAttribute && ((IcPasswordAttribute) attribute).getPasswordValue() == null) {
            UUID passwordPolicyId = system.getPasswordPolicyGenerate();
            // 
            String password = null;
            if (passwordPolicyId == null) {
                LOG.debug("Generate password policy for system [{}], not found. Password will be generate by default password policy", system.getCode());
                password = passwordPolicyService.generatePasswordByDefault();
            } else {
                LOG.debug("Generate password policy for system  [{}] found", system.getCode());
                password = passwordPolicyService.generatePassword(passwordPolicyService.get(passwordPolicyId));
            }
            // 
            connectorObject.getAttributes().remove(attribute);
            connectorObject.getAttributes().add(new IcPasswordAttributeImpl(ProvisioningService.PASSWORD_SCHEMA_PROPERTY_NAME, new GuardedString(password)));
            break;
        }
    }
    // 
    IcUidAttribute icUid = connectorFacade.createObject(systemService.getConnectorInstance(system), connectorConfig, connectorObject.getObjectClass(), connectorObject.getAttributes());
    // 
    // set connector object back to provisioning context
    provisioningOperation.getProvisioningContext().setConnectorObject(connectorObject);
    // has to be first - we need to replace guarded strings before systemEntityService.save(systemEntity)
    provisioningOperation = provisioningOperationService.save(provisioningOperation);
    return icUid;
}
Also used : IcPasswordAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcPasswordAttributeImpl) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcPasswordAttribute(eu.bcvsolutions.idm.ic.api.IcPasswordAttribute) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute) UUID(java.util.UUID) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 34 with SysSystemDto

use of eu.bcvsolutions.idm.acc.dto.SysSystemDto in project CzechIdMng by bcvsolutions.

the class ReadonlySystemProcessor method process.

@Override
public EventResult<SysProvisioningOperationDto> process(EntityEvent<SysProvisioningOperationDto> event) {
    SysProvisioningOperationDto provisioningOperation = event.getContent();
    SysSystemDto system = systemService.get(provisioningOperation.getSystem());
    boolean closed = false;
    if (system.isReadonly()) {
        String uid = provisioningOperationService.getByProvisioningOperation(provisioningOperation).getUid();
        ResultModel resultModel = new DefaultResultModel(AccResultCode.PROVISIONING_SYSTEM_READONLY, ImmutableMap.of("name", uid, "system", system.getName()));
        provisioningOperation.setResult(new OperationResult.Builder(OperationState.NOT_EXECUTED).setModel(resultModel).build());
        // 
        provisioningOperation = provisioningOperationService.save(provisioningOperation);
        // 
        LOG.info(resultModel.toString());
        notificationManager.send(AccModuleDescriptor.TOPIC_PROVISIONING, new IdmMessageDto.Builder().setModel(resultModel).build());
        // 
        closed = true;
    }
    // set back to event content
    event.setContent(provisioningOperation);
    return new DefaultEventResult<>(event, this, closed);
}
Also used : DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) ResultModel(eu.bcvsolutions.idm.core.api.dto.ResultModel) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 35 with SysSystemDto

use of eu.bcvsolutions.idm.acc.dto.SysSystemDto in project CzechIdMng by bcvsolutions.

the class DefaultSysSystemServiceFilterTest method testSystemVirtualFilter.

@Test
public void testSystemVirtualFilter() {
    SysSystemDto system1 = createSystem("test001" + System.currentTimeMillis(), true);
    createSystem("test002" + System.currentTimeMillis(), false);
    // 
    SysSystemFilter testFilter = new SysSystemFilter();
    testFilter.setVirtual(true);
    Page<SysSystemDto> pages = systemService.find(testFilter, null);
    assertEquals(1, pages.getTotalElements());
    assertEquals(system1.getId(), pages.getContent().get(0).getId());
}
Also used : SysSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Aggregations

SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)256 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)167 Test (org.junit.Test)167 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)98 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)82 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)56 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)52 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)50 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)45 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)42 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)42 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)32 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)32 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)30 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)29 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)29 SysProvisioningOperationFilter (eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter)29 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)28 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)27 IdmBasePermission (eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission)27