Search in sources :

Example 61 with DefaultEventResult

use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.

the class ProvisioningSendNotificationProcessor method process.

@Override
public EventResult<SysProvisioningOperationDto> process(EntityEvent<SysProvisioningOperationDto> event) {
    SysProvisioningOperationDto provisioningOperation = event.getContent();
    String uid = provisioningOperationService.getByProvisioningOperation(provisioningOperation).getUid();
    IdmIdentityDto identity = null;
    if (provisioningOperation.getEntityIdentifier() != null && SystemEntityType.IDENTITY == provisioningOperation.getEntityType()) {
        identity = identityService.get(provisioningOperation.getEntityIdentifier());
    }
    // TODO: identity or email null, send message to actual log user?
    if (identity != null && identity.getState() != IdentityState.CREATED) {
        for (IcAttribute attribute : provisioningOperationService.getFullConnectorObject(provisioningOperation).getAttributes()) {
            // TODO: send password always, when create?
            if (attribute instanceof IcPasswordAttribute && attribute.getValue() != null) {
                GuardedString password = ((IcPasswordAttribute) attribute).getPasswordValue();
                // 
                // send message with new password to identity, topic has connection to templates
                SysSystemDto system = systemService.get(provisioningOperation.getSystem());
                notificationManager.send(AccModuleDescriptor.TOPIC_NEW_PASSWORD, new IdmMessageDto.Builder().setLevel(NotificationLevel.SUCCESS).addParameter("systemName", system.getName()).addParameter("uid", uid).addParameter("password", password).build(), identity);
                break;
            }
        }
    }
    return new DefaultEventResult<>(event, this);
}
Also used : IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) 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) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 62 with DefaultEventResult

use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.

the class AccountSaveProcessor method process.

@Override
public EventResult<AccAccountDto> process(EntityEvent<AccAccountDto> event) {
    AccAccountDto entity = event.getContent();
    entity = service.saveInternal(entity);
    event.setContent(entity);
    return new DefaultEventResult<>(event, this);
}
Also used : DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto)

Example 63 with DefaultEventResult

use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.

the class IdentityAccountDeleteProcessor method process.

@Override
public EventResult<AccIdentityAccountDto> process(EntityEvent<AccIdentityAccountDto> event) {
    AccIdentityAccountDto entity = event.getContent();
    UUID account = entity.getAccount();
    AccAccountDto accountDto = accountService.get(account);
    Assert.notNull(accountDto, "Account cannot be null!");
    // We check if exists another (ownership) identity-accounts, if not
    // then we will delete account
    List<AccIdentityAccountDto> identityAccounts = findIdentityAccounts(account);
    boolean moreIdentityAccounts = identityAccounts.stream().filter(identityAccount -> {
        return identityAccount.isOwnership() && !identityAccount.equals(entity);
    }).findAny().isPresent();
    boolean deleteTargetAccount = (boolean) event.getProperties().get(AccIdentityAccountService.DELETE_TARGET_ACCOUNT_KEY);
    // If is account in protection, then we will not delete
    // identity-account
    // But is here exception from this. When is presented
    // attribute FORCE_DELETE_OF_IDENTITY_ACCOUNT_KEY, then
    // we will do delete of identity-account (it is important
    // for integrity ... for example during delete of whole
    // identity).
    boolean forceDeleteIdentityAccount = isForceDeleteAttributePresent(event.getProperties());
    if (!moreIdentityAccounts && entity.isOwnership()) {
        if (accountDto.isAccountProtectedAndValid()) {
            if (forceDeleteIdentityAccount) {
                // Target account and AccAccount will deleted!
                deleteTargetAccount = true;
            } else {
                throw new ResultCodeException(AccResultCode.ACCOUNT_CANNOT_BE_DELETED_IS_PROTECTED, ImmutableMap.of("uid", accountDto.getUid()));
            }
        // Is account protection activated on system mapping?
        // Set account as protected we can only on account without protection (event has already invalid protection)!
        } else if (!accountDto.isInProtection() && systemMappingService.isEnabledProtection(accountDto)) {
            // This identity account is last ... protection will be
            // activated
            activateProtection(accountDto);
            accountDto = accountService.save(accountDto);
            entity.setRoleSystem(null);
            entity.setIdentityRole(null);
            service.save(entity);
            doProvisioningSkipAccountProtection(accountDto, entity.getEntity());
            // identity-account
            if (forceDeleteIdentityAccount) {
                // Target account and AccAccount will be deleted!
                deleteTargetAccount = true;
            } else {
                return new DefaultEventResult<>(event, this);
            }
        }
    }
    service.deleteInternal(entity);
    if (!moreIdentityAccounts && entity.isOwnership()) {
        // We delete all identity accounts first
        identityAccounts.stream().filter(identityAccount -> identityAccount.isOwnership() && !identityAccount.equals(entity)).forEach(identityAccount -> {
            service.delete(identityAccount);
        });
        // Finally we can delete account
        accountService.publish(new AccountEvent(AccountEventType.DELETE, accountDto, ImmutableMap.of(AccAccountService.DELETE_TARGET_ACCOUNT_PROPERTY, deleteTargetAccount, AccAccountService.ENTITY_ID_PROPERTY, entity.getEntity())));
    }
    return new DefaultEventResult<>(event, this);
}
Also used : AccountEvent(eu.bcvsolutions.idm.acc.event.AccountEvent) ProvisioningEvent(eu.bcvsolutions.idm.acc.event.ProvisioningEvent) Autowired(org.springframework.beans.factory.annotation.Autowired) CoreEventProcessor(eu.bcvsolutions.idm.core.api.event.CoreEventProcessor) CoreEvent(eu.bcvsolutions.idm.core.api.event.CoreEvent) SysSystemMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemMappingService) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) Map(java.util.Map) IdentityAccountEventType(eu.bcvsolutions.idm.acc.event.IdentityAccountEvent.IdentityAccountEventType) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) AccountEventType(eu.bcvsolutions.idm.acc.event.AccountEvent.AccountEventType) EventResult(eu.bcvsolutions.idm.core.api.event.EventResult) EntityEvent(eu.bcvsolutions.idm.core.api.event.EntityEvent) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) Description(org.springframework.context.annotation.Description) ImmutableMap(com.google.common.collect.ImmutableMap) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) DateTime(org.joda.time.DateTime) UUID(java.util.UUID) Serializable(java.io.Serializable) ProvisioningEventType(eu.bcvsolutions.idm.acc.event.ProvisioningEvent.ProvisioningEventType) List(java.util.List) Component(org.springframework.stereotype.Component) AccAccountService(eu.bcvsolutions.idm.acc.service.api.AccAccountService) ProvisioningService(eu.bcvsolutions.idm.acc.service.api.ProvisioningService) AccIdentityAccountService(eu.bcvsolutions.idm.acc.service.api.AccIdentityAccountService) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) AccResultCode(eu.bcvsolutions.idm.acc.domain.AccResultCode) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) Assert(org.springframework.util.Assert) AccountEvent(eu.bcvsolutions.idm.acc.event.AccountEvent) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) UUID(java.util.UUID) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)

Example 64 with DefaultEventResult

use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.

the class LongRunningTaskEndProcessor method process.

@Override
public EventResult<IdmLongRunningTaskDto> process(EntityEvent<IdmLongRunningTaskDto> event) {
    IdmLongRunningTaskDto task = event.getContent();
    // end task
    task.setRunning(false);
    // and persist state
    service.save(task);
    event.setContent(task);
    // 
    return new DefaultEventResult<>(event, this);
}
Also used : IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult)

Example 65 with DefaultEventResult

use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.

the class ContractGuaranteeDeleteProcessor method process.

@Override
public EventResult<IdmContractGuaranteeDto> process(EntityEvent<IdmContractGuaranteeDto> event) {
    IdmContractGuaranteeDto dto = event.getContent();
    // 
    contractGuaranteeService.deleteInternal(dto);
    // 
    return new DefaultEventResult<>(event, this);
}
Also used : IdmContractGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult)

Aggregations

DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)91 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)20 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)12 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)11 UUID (java.util.UUID)11 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)10 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)7 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)7 PasswordChangeDto (eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto)6 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)5 IdmEntityEventDto (eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto)5 IdmPasswordPolicyDto (eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto)5 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)5 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)5 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)4 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)4 DefaultResultModel (eu.bcvsolutions.idm.core.api.dto.DefaultResultModel)4 IdmMessageDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto)4 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)4 ArrayList (java.util.ArrayList)4