use of eu.bcvsolutions.idm.core.model.event.IdentityEvent in project CzechIdMng by bcvsolutions.
the class PasswordExpiredTaskExecutor method processItem.
@Override
public Optional<OperationResult> processItem(IdmPasswordDto dto) {
IdmIdentityDto identity = (IdmIdentityDto) lookupService.lookupDto(IdmIdentityDto.class, dto.getIdentity());
LOG.info("Publishing [{}] event to identity [{}], password expired in [{}]", IdentityEventType.PASSWORD_EXPIRED, identity.getUsername(), dto.getValidTill());
try {
entityEventManager.process(new IdentityEvent(IdentityEventType.PASSWORD_EXPIRED, identity));
return Optional.of(new OperationResult.Builder(OperationState.EXECUTED).build());
} catch (Exception ex) {
LOG.error("Publishing [{}] event to identity [{}], password expired in [{}] failed", IdentityEventType.PASSWORD_EXPIRED, dto.getIdentity(), dto.getValidTill(), ex);
return Optional.of(new OperationResult.Builder(OperationState.EXCEPTION).setCause(ex).build());
}
}
use of eu.bcvsolutions.idm.core.model.event.IdentityEvent in project CzechIdMng by bcvsolutions.
the class IdentityContractExclusionProcessor method process.
/**
* Check identity state after contract is excluded
*
* @param contract
* @param skipRecalculation Skip automatic role recalculation
* @return
*/
public OperationResult process(IdmIdentityContractDto contract, Boolean skipRecalculation) {
IdmIdentityDto identity = identityService.get(contract.getIdentity());
IdentityState newState = identityService.evaluateState(identity.getId());
//
if (identity.getState() != newState) {
LOG.info("Change identity [{}] state [{}]", identity.getUsername(), newState);
//
identity.setState(newState);
// is necessary publish new event with skip recalculation automatic roles
IdentityEvent identityEvent = new IdentityEvent(IdentityEventType.UPDATE, identity);
identityEvent.getProperties().put(IdmAutomaticRoleAttributeService.SKIP_RECALCULATION, skipRecalculation);
identityService.publish(identityEvent);
}
return new OperationResult.Builder(OperationState.EXECUTED).build();
}
use of eu.bcvsolutions.idm.core.model.event.IdentityEvent in project CzechIdMng by bcvsolutions.
the class IdentityContractSaveProcessor method process.
@Override
public EventResult<IdmIdentityContractDto> process(EntityEvent<IdmIdentityContractDto> event) {
IdmIdentityContractDto contract = event.getContent();
contract = service.saveInternal(contract);
event.setContent(contract);
//
// check identity state
IdmIdentityContractDto previousContract = event.getOriginalSource();
IdmIdentityDto identity = DtoUtils.getEmbedded(contract, IdmIdentityContract_.identity.getName(), IdmIdentityDto.class);
if ((identity.getState() == IdentityState.CREATED || identity.isDisabled()) && contractChanged(previousContract, contract)) {
// synchronize identity states, which has no effect on HR processes
identity = identityService.get(contract.getIdentity());
IdentityState newState = identityService.evaluateState(identity.getId());
if (newState.isDisabled() && identity.getState() != newState) {
identity.setState(newState);
// publish new save event for identity with skip recalculation
IdentityEvent identityEvent = new IdentityEvent(IdentityEventType.UPDATE, identity);
identityEvent.getProperties().put(IdmAutomaticRoleAttributeService.SKIP_RECALCULATION, true);
identityService.publish(identityEvent);
}
}
//
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.model.event.IdentityEvent in project CzechIdMng by bcvsolutions.
the class IdentitySynchronizationExecutor method callProvisioningForEntity.
/**
* Call provisioning for given account
*
* @param entity
* @param entityType
* @param logItem
*/
@Override
protected void callProvisioningForEntity(IdmIdentityDto entity, SystemEntityType entityType, SysSyncItemLogDto logItem) {
addToItemLog(logItem, MessageFormat.format("Call provisioning (process IdentityEventType.SAVE) for identity ({0}) with username ({1}).", entity.getId(), entity.getUsername()));
//
IdentityEvent event = new IdentityEvent(IdentityEventType.UPDATE, entity);
// We don't want recalculate automatic role by attribute recalculation for every contract.
// Recalculation will be started only once.
event.getProperties().put(IdmAutomaticRoleAttributeService.SKIP_RECALCULATION, Boolean.TRUE);
identityService.publish(event);
}
use of eu.bcvsolutions.idm.core.model.event.IdentityEvent in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityServiceIntegrationTest method testSkipDefaultContract.
/**
* When identity is created with the event property
* IdmIdentityContractService.SKIP_CREATION_OF_DEFAULT_POSITION = TRUE, then
* default contract haven't to be created.
*/
@Test
public void testSkipDefaultContract() {
IdmIdentityDto identity = new IdmIdentityDto();
String username = "contract_test_" + System.currentTimeMillis();
identity.setUsername(username);
// confidential storage
identity.setPassword(new GuardedString("heslo"));
identity.setFirstName("Test");
identity.setLastName("Identity");
EntityEvent<IdmIdentityDto> event = new IdentityEvent(IdentityEventType.CREATE, identity, ImmutableMap.of(// In the identity sync are creation of the default contract skipped.
IdmIdentityContractService.SKIP_CREATION_OF_DEFAULT_POSITION, Boolean.TRUE));
identity = identityService.publish(event).getContent();
//
List<IdmIdentityContractDto> contracts = identityContractService.findAllByIdentity(identity.getId());
assertEquals(0, contracts.size());
}
Aggregations