Search in sources :

Example 66 with AccAccountDto

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

the class DefaultAccAccountService method delete.

@Override
@Transactional
public void delete(AccAccountDto account, BasePermission... permission) {
    Assert.notNull(account);
    // delete all identity accounts (call event)
    AccIdentityAccountFilter identityAccountFilter = new AccIdentityAccountFilter();
    identityAccountFilter.setAccountId(account.getId());
    List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(identityAccountFilter, null).getContent();
    identityAccounts.forEach(identityAccount -> {
        identityAccountService.delete(identityAccount);
    });
    AccAccountDto potentialProtectedAccount = get(account);
    // Account was already deleted during relations identity-accounts deletion
    if (potentialProtectedAccount == null) {
        return;
    }
    // rollback).
    if (!account.isAccountProtectedAndValid() && potentialProtectedAccount.isAccountProtectedAndValid()) {
        return;
    }
    this.publish(new AccountEvent(AccountEventType.DELETE, account, ImmutableMap.of(AccAccountService.DELETE_TARGET_ACCOUNT_PROPERTY, Boolean.TRUE)));
}
Also used : AccountEvent(eu.bcvsolutions.idm.acc.event.AccountEvent) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 67 with AccAccountDto

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

the class DefaultAccAccountService method toDto.

@Override
protected AccAccountDto toDto(AccAccount entity, AccAccountDto dto) {
    AccAccountDto newDto = super.toDto(entity, dto);
    // if dto exists add real uid
    if (newDto != null) {
        if (newDto.getSystemEntity() != null) {
            SysSystemEntityDto systemEntity = DtoUtils.getEmbedded(newDto, AccAccount_.systemEntity, SysSystemEntityDto.class);
            newDto.setRealUid(systemEntity.getUid());
        } else {
            // If system entity do not exist, then return uid from account.
            newDto.setRealUid(newDto.getUid());
        }
    }
    return newDto;
}
Also used : AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)

Example 68 with AccAccountDto

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

the class TreeSynchronizationExecutor method doUpdateEntity.

/**
 * Fill data from IC attributes to entity (EAV and confidential storage too)
 *
 * @param account
 * @param entityType
 * @param uid
 * @param icAttributes
 * @param mappedAttributes
 * @param log
 * @param logItem
 * @param actionLogs
 */
@Override
protected void doUpdateEntity(SynchronizationContext context) {
    String uid = context.getUid();
    SysSyncLogDto log = context.getLog();
    SysSyncItemLogDto logItem = context.getLogItem();
    List<SysSyncActionLogDto> actionLogs = context.getActionLogs();
    List<SysSystemAttributeMappingDto> mappedAttributes = context.getMappedAttributes();
    AccAccountDto account = context.getAccount();
    List<IcAttribute> icAttributes = context.getIcObject().getAttributes();
    UUID entityId = getEntityByAccount(account.getId());
    IdmTreeNodeDto treeNode = null;
    if (entityId != null) {
        treeNode = treeNodeService.get(entityId);
    }
    if (treeNode != null) {
        // Update entity
        treeNode = fillEntity(mappedAttributes, uid, icAttributes, treeNode, false, context);
        treeNode = this.save(treeNode, true);
        // Update extended attribute (entity must be persisted first)
        updateExtendedAttributes(mappedAttributes, uid, icAttributes, treeNode, false, context);
        // Update confidential attribute (entity must be persisted first)
        updateConfidentialAttributes(mappedAttributes, uid, icAttributes, treeNode, false, context);
        // TreeNode Updated
        addToItemLog(logItem, MessageFormat.format("TreeNode with id {0} was updated", treeNode.getId()));
        if (logItem != null) {
            logItem.setDisplayName(treeNode.getName());
        }
        // Call provisioning for entity
        this.callProvisioningForEntity(treeNode, context.getEntityType(), logItem);
        return;
    } else {
        addToItemLog(logItem, "Tree - account relation (with ownership = true) was not found!");
        initSyncActionLog(SynchronizationActionType.UPDATE_ENTITY, OperationResultType.WARNING, logItem, log, actionLogs);
        return;
    }
}
Also used : SysSyncActionLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) UUID(java.util.UUID) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)

Example 69 with AccAccountDto

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

the class DefaultTestHelper method createIdentityAccount.

@Override
public AccIdentityAccountDto createIdentityAccount(SysSystemDto system, IdmIdentityDto identity) {
    AccAccountDto account = new AccAccountDto();
    account.setSystem(system.getId());
    account.setUid(identity.getUsername());
    account.setAccountType(AccountType.PERSONAL);
    account = accountService.save(account);
    AccIdentityAccountDto accountIdentity = new AccIdentityAccountDto();
    accountIdentity.setIdentity(identity.getId());
    accountIdentity.setOwnership(true);
    accountIdentity.setAccount(account.getId());
    return identityAccountService.save(accountIdentity);
}
Also used : AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)

Example 70 with AccAccountDto

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

the class IdentityAccountByRoleEvaluatorIntegrationTest method testCannotReadIdentityAccount.

@Test(expected = ForbiddenEntityException.class)
public void testCannotReadIdentityAccount() {
    IdmIdentityDto identity;
    AccIdentityAccountDto accountIdentityOne;
    try {
        loginAsAdmin(InitApplicationData.ADMIN_USERNAME);
        // 
        identity = helper.createIdentity();
        SysSystemDto system = helper.createTestResourceSystem(true);
        AccAccountDto accountOne = new AccAccountDto();
        accountOne.setSystem(system.getId());
        accountOne.setUid(identity.getUsername());
        accountOne.setAccountType(AccountType.PERSONAL);
        accountOne = accountService.save(accountOne);
        accountIdentityOne = new AccIdentityAccountDto();
        accountIdentityOne.setIdentity(identity.getId());
        accountIdentityOne.setOwnership(true);
        accountIdentityOne.setAccount(accountOne.getId());
        accountIdentityOne = identityAccountService.save(accountIdentityOne);
    } finally {
        logout();
    }
    // check
    try {
        loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
        identityAccountService.get(accountIdentityOne.getId(), IdmBasePermission.READ);
    } finally {
        logout();
    }
}
Also used : AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)90 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)59 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)47 Test (org.junit.Test)45 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)44 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)33 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)29 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)25 AccAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter)19 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)18 TestResource (eu.bcvsolutions.idm.acc.entity.TestResource)18 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)16 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)16 ArrayList (java.util.ArrayList)16 SysSyncItemLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto)15 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)14 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)14 UUID (java.util.UUID)14 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)13 PasswordChangeDto (eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto)13