use of eu.bcvsolutions.idm.acc.event.IdentityAccountEvent in project CzechIdMng by bcvsolutions.
the class RoleRequestRealizationProcessor method process.
@Override
public EventResult<IdmRoleRequestDto> process(EntityEvent<IdmRoleRequestDto> event) {
IdmRoleRequestDto request = event.getContent();
IdmIdentityDto identity = identityService.get(request.getApplicant());
Set<IdmIdentityRoleDto> addedIdentityRoles = this.getSetProperty(IdentityRoleEvent.PROPERTY_ASSIGNED_NEW_ROLES, event, IdmIdentityRoleDto.class);
Set<IdmIdentityRoleDto> updatedIdentityRoles = this.getSetProperty(IdentityRoleEvent.PROPERTY_ASSIGNED_UPDATED_ROLES, event, IdmIdentityRoleDto.class);
Set<UUID> removedIdentityAccounts = this.getSetProperty(IdmAccountDto.IDENTITY_ACCOUNT_FOR_DELAYED_ACM, event, UUID.class);
Set<UUID> accountsForAdditionalProvisioning = this.getSetProperty(IdmAccountDto.ACCOUNT_FOR_ADDITIONAL_PROVISIONING, event, UUID.class);
boolean skipProvisioning = this.getBooleanProperty(ProvisioningService.SKIP_PROVISIONING, event.getProperties());
Set<UUID> accountsForProvisioning = new HashSet<>(accountsForAdditionalProvisioning);
if (addedIdentityRoles.size() > 0) {
LOG.debug("Call account management for identity [{}] and new identity-roles [{}]", identity.getUsername(), addedIdentityRoles);
List<UUID> accounts = accountManagementService.resolveNewIdentityRoles(identity, addedIdentityRoles.toArray(new IdmIdentityRoleDto[0]));
addAccounts(accountsForProvisioning, accounts);
}
if (updatedIdentityRoles.size() > 0) {
LOG.debug("Call account management for identity [{}] and updated identity-roles [{}]", identity.getUsername(), updatedIdentityRoles);
List<UUID> accounts = accountManagementService.resolveUpdatedIdentityRoles(identity, updatedIdentityRoles.toArray(new IdmIdentityRoleDto[0]));
addAccounts(accountsForProvisioning, accounts);
}
// Remove delayed identity-accounts (includes provisioning)
if (removedIdentityAccounts.size() > 0) {
LOG.debug("Call account management for identity [{}] - remove identity-accounts [{}]", identity.getUsername(), removedIdentityAccounts);
removedIdentityAccounts.stream().distinct().forEach(identityAccountId -> {
AccIdentityAccountDto identityAccountDto = identityAccountService.get(identityAccountId);
if (identityAccountDto != null) {
IdentityAccountEvent eventIdentityAccount = new IdentityAccountEvent(IdentityAccountEventType.DELETE, identityAccountDto, ImmutableMap.of(AccIdentityAccountService.DELETE_TARGET_ACCOUNT_KEY, Boolean.TRUE, AccIdentityAccountService.FORCE_DELETE_OF_IDENTITY_ACCOUNT_KEY, Boolean.FALSE, IdmRoleRequestService.ROLE_REQUEST_ID_KEY, request.getId()));
identityAccountService.publish(eventIdentityAccount);
accountsForProvisioning.add(identityAccountDto.getAccount());
}
});
}
// Init context in identity DTO and set ID of role-request to it.
initContext(identity, request);
// Skip provisionig
if (skipProvisioning) {
return new DefaultEventResult<>(event, this);
}
// Provisioning for modified account
accountsForProvisioning.forEach(accountId -> {
AccAccountDto account = accountService.get(accountId);
if (account != null) {
// Account could be null (was deleted).
LOG.debug("Call provisioning for identity [{}] and account [{}]", identity.getUsername(), account.getUid());
provisioningService.doProvisioning(account, identity);
}
});
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.acc.event.IdentityAccountEvent in project CzechIdMng by bcvsolutions.
the class DefaultAccIdentityAccountService method delete.
private void delete(AccIdentityAccountDto entity, boolean deleteTargetAccount, boolean forceDelete, BasePermission... permission) {
Assert.notNull(entity, "Entity is required.");
checkAccess(this.getEntity(entity.getId()), permission);
//
LOG.debug("Deleting identity account [{}]", entity);
entityEventManager.process(new IdentityAccountEvent(IdentityAccountEventType.DELETE, entity, ImmutableMap.of(AccIdentityAccountService.DELETE_TARGET_ACCOUNT_KEY, deleteTargetAccount, AccIdentityAccountService.FORCE_DELETE_OF_IDENTITY_ACCOUNT_KEY, forceDelete)));
}
Aggregations