Search in sources :

Example 1 with IdentityRoleEvent

use of eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent in project CzechIdMng by bcvsolutions.

the class DefaultIdmAutomaticRoleAttributeService method removeAutomaticRoles.

@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void removeAutomaticRoles(UUID contractId, Set<AbstractIdmAutomaticRoleDto> automaticRoles) {
    for (AbstractIdmAutomaticRoleDto autoRole : automaticRoles) {
        IdmIdentityRoleFilter identityRoleFilter = new IdmIdentityRoleFilter();
        identityRoleFilter.setIdentityContractId(contractId);
        identityRoleFilter.setAutomaticRoleId(autoRole.getId());
        // TODO: possible performance update with pageable
        for (IdmIdentityRoleDto identityRole : identityRoleService.find(identityRoleFilter, null).getContent()) {
            // skip check granted authorities
            IdentityRoleEvent event = new IdentityRoleEvent(IdentityRoleEventType.DELETE, identityRole);
            event.getProperties().put(IdmIdentityRoleService.SKIP_CHECK_AUTHORITIES, Boolean.TRUE);
            identityRoleService.publish(event);
        }
    }
}
Also used : IdentityRoleEvent(eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent) AbstractIdmAutomaticRoleDto(eu.bcvsolutions.idm.core.api.dto.AbstractIdmAutomaticRoleDto) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with IdentityRoleEvent

use of eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent in project CzechIdMng by bcvsolutions.

the class DefaultIdmRoleTreeNodeService method addAutomaticRoles.

@Override
@Transactional
public void addAutomaticRoles(IdmIdentityContractDto contract, Set<IdmRoleTreeNodeDto> automaticRoles) {
    // original method assignAutomaticRoles has also only @Transactional without reguired new
    for (AbstractIdmAutomaticRoleDto autoRole : automaticRoles) {
        // create identity role directly
        IdmIdentityRoleDto identityRole = new IdmIdentityRoleDto();
        identityRole.setRoleTreeNode(autoRole.getId());
        identityRole.setIdentityContract(contract.getId());
        identityRole.setRole(autoRole.getRole());
        identityRole.setValidFrom(contract.getValidFrom());
        identityRole.setValidTill(contract.getValidTill());
        // 
        // start event with skip check authorities
        IdentityRoleEvent event = new IdentityRoleEvent(IdentityRoleEventType.CREATE, identityRole);
        event.getProperties().put(IdmIdentityRoleService.SKIP_CHECK_AUTHORITIES, Boolean.TRUE);
        identityRoleService.publish(event);
    }
}
Also used : IdentityRoleEvent(eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent) AbstractIdmAutomaticRoleDto(eu.bcvsolutions.idm.core.api.dto.AbstractIdmAutomaticRoleDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with IdentityRoleEvent

use of eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent in project CzechIdMng by bcvsolutions.

the class DefaultIdmRoleRequestService method removeAssignedRole.

/**
 * Remove identity-role by concept
 *
 * @param concept
 * @param request
 * @param requestEvent
 */
private void removeAssignedRole(IdmConceptRoleRequestDto concept, IdmRoleRequestDto request, EntityEvent<IdmRoleRequestDto> requestEvent) {
    Assert.notNull(concept.getIdentityRole(), "IdentityRole is mandatory for delete!");
    IdmIdentityRoleDto identityRole = DtoUtils.getEmbedded(concept, IdmConceptRoleRequest_.identityRole.getName(), IdmIdentityRoleDto.class, (IdmIdentityRoleDto) null);
    if (identityRole == null) {
        identityRole = identityRoleThinService.get(concept.getIdentityRole());
    }
    if (identityRole != null) {
        concept.setState(RoleRequestState.EXECUTED);
        // we have to remove relation on
        concept.setIdentityRole(null);
        // deleted identityRole
        String message = MessageFormat.format("IdentityRole [{0}] (reqested in concept [{1}]) was deleted (from this role request).", identityRole.getId(), concept.getId());
        conceptRoleRequestService.addToLog(concept, message);
        conceptRoleRequestService.addToLog(request, message);
        conceptRoleRequestService.save(concept);
        IdentityRoleEvent event = new IdentityRoleEvent(IdentityRoleEventType.DELETE, identityRole, ImmutableMap.of(IdmAccountDto.SKIP_PROPAGATE, Boolean.TRUE));
        identityRoleService.publish(event, requestEvent);
        // Add list of identity-accounts for delayed ACM to parent event
        Set<UUID> subIdentityAccountsForAcm = event.getSetProperty(IdmAccountDto.IDENTITY_ACCOUNT_FOR_DELAYED_ACM, UUID.class);
        Set<UUID> identityAccountsForAcm = requestEvent.getSetProperty(IdmAccountDto.IDENTITY_ACCOUNT_FOR_DELAYED_ACM, UUID.class);
        identityAccountsForAcm.addAll(subIdentityAccountsForAcm);
        // Add list of accounts for additional provisioning to parent event
        Set<UUID> subIdentityAccountsForProvisioning = event.getSetProperty(IdmAccountDto.ACCOUNT_FOR_ADDITIONAL_PROVISIONING, UUID.class);
        Set<UUID> identityAccountsForProvisioning = requestEvent.getSetProperty(IdmAccountDto.ACCOUNT_FOR_ADDITIONAL_PROVISIONING, UUID.class);
        identityAccountsForProvisioning.addAll(subIdentityAccountsForProvisioning);
        // Removed assigned roles by business roles
        Set<UUID> subRemovedIdentityRoles = event.getSetProperty(IdentityRoleEvent.PROPERTY_ASSIGNED_REMOVED_ROLES, UUID.class);
        // Add to parent event
        Set<UUID> removedIdentityRoles = requestEvent.getSetProperty(IdentityRoleEvent.PROPERTY_ASSIGNED_REMOVED_ROLES, UUID.class);
        removedIdentityRoles.addAll(subRemovedIdentityRoles);
        removedIdentityRoles.add(identityRole.getId());
    }
}
Also used : IdentityRoleEvent(eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) UUID(java.util.UUID)

Example 4 with IdentityRoleEvent

use of eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent in project CzechIdMng by bcvsolutions.

the class DefaultIdmRoleTreeNodeService method createIdentityRole.

/**
 * Method create identity role and start event with create
 * the identity role and skip check authorities.
 *
 * @param contract
 * @param automaticRoles
 */
private void createIdentityRole(IdmIdentityContractDto contract, IdmContractPositionDto contractPosition, Set<IdmRoleTreeNodeDto> automaticRoles) {
    for (AbstractIdmAutomaticRoleDto autoRole : automaticRoles) {
        // create identity role directly
        IdmIdentityRoleDto identityRole = new IdmIdentityRoleDto();
        identityRole.setAutomaticRole(autoRole.getId());
        identityRole.setIdentityContract(contract.getId());
        identityRole.setContractPosition(contractPosition == null ? null : contractPosition.getId());
        identityRole.setRole(autoRole.getRole());
        identityRole.setValidFrom(contract.getValidFrom());
        identityRole.setValidTill(contract.getValidTill());
        // 
        // start event with skip check authorities
        IdentityRoleEvent event = new IdentityRoleEvent(IdentityRoleEventType.CREATE, identityRole);
        event.getProperties().put(IdmIdentityRoleService.SKIP_CHECK_AUTHORITIES, Boolean.TRUE);
        identityRoleService.publish(event);
    }
}
Also used : IdentityRoleEvent(eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent) AbstractIdmAutomaticRoleDto(eu.bcvsolutions.idm.core.api.dto.AbstractIdmAutomaticRoleDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)

Example 5 with IdentityRoleEvent

use of eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent in project CzechIdMng by bcvsolutions.

the class DefaultIdmRoleTreeNodeService method removeAutomaticRoles.

@Override
public void removeAutomaticRoles(IdmIdentityRoleDto identityRole, Set<IdmRoleTreeNodeDto> automaticRoles) {
    IdentityRoleEvent event = new IdentityRoleEvent(IdentityRoleEventType.DELETE, identityRole);
    event.getProperties().put(IdmIdentityRoleService.SKIP_CHECK_AUTHORITIES, Boolean.TRUE);
    identityRoleService.publish(event);
}
Also used : IdentityRoleEvent(eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent)

Aggregations

IdentityRoleEvent (eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent)14 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)11 Transactional (org.springframework.transaction.annotation.Transactional)6 IdmIdentityRoleFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter)5 AbstractIdmAutomaticRoleDto (eu.bcvsolutions.idm.core.api.dto.AbstractIdmAutomaticRoleDto)4 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)3 UUID (java.util.UUID)3 IdmIdentityRoleValidRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleValidRequestDto)1 IdmRoleCompositionDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto)1 IdmConceptRoleRequestFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmConceptRoleRequestFilter)1 IdmRoleCompositionFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleCompositionFilter)1 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)1 Serializable (java.io.Serializable)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1