use of eu.bcvsolutions.idm.core.model.event.IdentityEvent in project CzechIdMng by bcvsolutions.
the class EntityEventProcessorUnitTest method testSupportAllIdentityEvents.
@Test
public void testSupportAllIdentityEvents() {
EntityEventProcessor<?> processor = new EventProcessorIdentity();
assertTrue(processor.supports(new IdentityEvent(IdentityEventType.CREATE, new IdmIdentityDto())));
assertTrue(processor.supports(new IdentityEvent(IdentityEventType.UPDATE, new IdmIdentityDto())));
assertTrue(processor.supports(new IdentityEvent(IdentityEventType.DELETE, new IdmIdentityDto())));
assertFalse(processor.supports(new RoleEvent(RoleEventType.DELETE, new IdmRoleDto())));
assertTrue(processor.supports(new CoreEvent<IdmIdentityDto>(CustomType.SAVE, new IdmIdentityDto())));
assertTrue(processor.supports(new CoreEvent<>(CustomType.CUSTOM, new IdmIdentityDto())));
}
use of eu.bcvsolutions.idm.core.model.event.IdentityEvent in project CzechIdMng by bcvsolutions.
the class EntityEventProcessorUnitTest method testSuppotsAll.
@Test
public void testSuppotsAll() {
EntityEventProcessor<?> processor = new EventProcessorBase();
assertTrue(processor.supports(new IdentityEvent(IdentityEventType.UPDATE, new IdmIdentityDto())));
assertTrue(processor.supports(new IdentityEvent(IdentityEventType.DELETE, new IdmIdentityDto())));
assertTrue(processor.supports(new IdentityContractEvent(IdentityContractEventType.DELETE, new IdmIdentityContractDto())));
assertTrue(processor.supports(new CoreEvent<IdmIdentityDto>(CustomType.SAVE, new IdmIdentityDto())));
assertTrue(processor.supports(new CoreEvent<>(CustomType.CUSTOM, new IdmIdentityDto())));
assertTrue(processor.supports(new CoreEvent<IdmIdentityContractDto>(IdentityContractEventType.UPDATE, new IdmIdentityContractDto())));
}
use of eu.bcvsolutions.idm.core.model.event.IdentityEvent in project CzechIdMng by bcvsolutions.
the class IdentityContractEnableProcessor method process.
/**
* Check identity state after contract is enabled
*
* @param contract
* @param skipRecalculation Skip automatic role recalculation
* @return
*/
public OperationResult process(IdmIdentityContractDto contract, Boolean skipRecalculation) {
if (contract.isValid() && contract.getState() != ContractState.EXCLUDED) {
IdmIdentityDto identity = identityService.get(contract.getIdentity());
IdentityState newState = identityService.evaluateState(identity.getId());
// we want to enable identity with contract other than default one
if (newState == IdentityState.VALID && (identity.isDisabled() || identity.getState() == IdentityState.CREATED)) {
LOG.info("Change identity [{}] state [{}]", identity.getUsername(), IdentityState.VALID);
//
identity.setState(IdentityState.VALID);
// is neccessary publish new event with skip recalculation automatic roles
IdentityEvent event = new IdentityEvent(IdentityEventType.UPDATE, identity);
event.getProperties().put(IdmAutomaticRoleAttributeService.SKIP_RECALCULATION, skipRecalculation);
identityService.publish(event);
}
}
return new OperationResult.Builder(OperationState.EXECUTED).build();
}
use of eu.bcvsolutions.idm.core.model.event.IdentityEvent in project CzechIdMng by bcvsolutions.
the class IdentityContractEndProcessor method process.
/**
* Check identity state after contract ended
*
* @param contract
* @param skipRecalculation Skip automatic role recalculation
* @return
*/
public OperationResult process(IdmIdentityContractDto contract, Boolean skipRecalculation) {
// update identity state
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 neccessary 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);
}
// TODO: remove? It's solved by different process
if (!contract.isValidNowOrInFuture()) {
identityRoleService.findAllByContract(contract.getId()).forEach(role -> {
identityRoleService.delete(role);
});
}
return new OperationResult.Builder(OperationState.EXECUTED).build();
}
use of eu.bcvsolutions.idm.core.model.event.IdentityEvent in project CzechIdMng by bcvsolutions.
the class EntityEventProcessorUnitTest method testHasEventType.
@Test
public void testHasEventType() {
EntityEvent<IdmIdentityDto> event = new IdentityEvent(IdentityEventType.UPDATE, new IdmIdentityDto());
//
assertTrue(event.hasType(IdentityEventType.UPDATE));
assertFalse(event.hasType(IdentityEventType.CREATE));
}
Aggregations