use of eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto in project CzechIdMng by bcvsolutions.
the class AdUserConnectorType method createEntityStateWithTestUser.
/**
* Create entity state for wizard test user
*/
private IdmEntityStateDto createEntityStateWithTestUser(SysSystemDto systemDto, String createdUserDN) {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("entityId", systemDto.getId());
// Mark state with created user DN.
parameters.put(TEST_CREATED_USER_DN_KEY, createdUserDN);
DefaultResultModel resultModel = new DefaultResultModel(AccResultCode.WIZARD_AD_CREATED_TEST_USER_DN, parameters);
IdmEntityStateDto entityStateDto = new IdmEntityStateDto();
entityStateDto.setResult(new OperationResultDto.Builder(OperationState.CREATED).setModel(resultModel).build());
return entityStateManager.saveState(systemDto, entityStateDto);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto in project CzechIdMng by bcvsolutions.
the class ProvisioningUniformPasswordNotificationProcessor method process.
@Override
@SuppressWarnings("unchecked")
public EventResult<SysProvisioningOperationDto> process(EntityEvent<SysProvisioningOperationDto> event) {
SysProvisioningOperationDto provisioningOperation = event.getContent();
IdmIdentityDto identityDto = null;
if (provisioningOperation.getEntityIdentifier() != null && SystemEntityType.IDENTITY == provisioningOperation.getEntityType()) {
identityDto = identityService.get(provisioningOperation.getEntityIdentifier());
}
if (identityDto != null && identityDto.getState() != IdentityState.CREATED) {
// Notification will be send after end of sync.
if (identityDto.getId() != null) {
IdmEntityStateDto uniformPasswordState = uniformPasswordManager.getEntityState(identityDto.getId(), identityDto.getClass(), provisioningOperation.getTransactionId());
UUID systemId = provisioningOperation.getSystem();
if (systemId != null) {
AccUniformPasswordDto uniformPasswordBySystem = uniformPasswordManager.getUniformPasswordBySystem(systemId);
if (uniformPasswordBySystem != null && uniformPasswordState != null) {
// Add name of uniform password group to the entity state.
uniformPasswordManager.addSystemNameToEntityState(uniformPasswordState, uniformPasswordBySystem.getCode());
ResultModel model = uniformPasswordState.getResult().getModel();
// Create new parameters for entity state.
HashMap<String, Object> newParameters = Maps.newHashMap(model.getParameters());
// Add system entity ID to entity state for uniform password (could be used in bulk notification).
UUID systemEntityId = provisioningOperation.getSystemEntity();
if (systemEntityId != null) {
Object successSystemEntitiesObj = model.getParameters().get(UniformPasswordManager.SUCCESS_SYSTEM_ENTITIES);
Set<UUID> successSystemEntities = null;
if (successSystemEntitiesObj instanceof Set) {
successSystemEntities = (Set<UUID>) successSystemEntitiesObj;
} else {
successSystemEntities = Sets.newHashSet();
}
successSystemEntities.add(systemEntityId);
newParameters.put(UniformPasswordManager.SUCCESS_SYSTEM_ENTITIES, successSystemEntities);
}
// Save entity state with new parameters.
uniformPasswordState.getResult().setModel(new DefaultResultModel(CoreResultCode.IDENTITY_UNIFORM_PASSWORD, newParameters));
entityStateManager.saveState(null, uniformPasswordState);
}
}
}
}
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto in project CzechIdMng by bcvsolutions.
the class AdGroupConnectorTypeTest method testDeleteUser.
@Test
public void testDeleteUser() {
ConnectorType connectorType = connectorManager.getConnectorType(MockAdGroupConnectorType.NAME);
ConnectorTypeDto connectorTypeDto = connectorManager.convertTypeToDto(connectorType);
SysSystemDto systemDto = createSystem(this.getHelper().createName(), connectorTypeDto);
connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.SYSTEM_DTO_KEY, systemDto.getId().toString());
connectorTypeDto.setWizardStepName(MockAdGroupConnectorType.STEP_CREATE_USER_TEST);
// Execute step for testing permissions to create user.
ConnectorTypeDto stepExecutedResult = connectorManager.execute(connectorTypeDto);
String entityStateId = stepExecutedResult.getMetadata().get(MockAdGroupConnectorType.ENTITY_STATE_WITH_TEST_CREATED_USER_DN_KEY);
assertNotNull(entityStateId);
IdmEntityStateDto entityStateDto = entityStateService.get(UUID.fromString(entityStateId));
assertNotNull(entityStateDto);
connectorTypeDto.setWizardStepName(MockAdGroupConnectorType.STEP_DELETE_USER_TEST);
// Execute step for testing permissions to delete user.
connectorManager.execute(connectorTypeDto);
entityStateDto = entityStateService.get(UUID.fromString(entityStateId));
assertNull(entityStateDto);
// Clean
systemService.delete(systemDto);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto in project CzechIdMng by bcvsolutions.
the class AdUserConnectorTypeTest method testAssignUserToGroup.
@Test
public void testAssignUserToGroup() {
ConnectorType connectorType = connectorManager.getConnectorType(MockAdUserConnectorType.NAME);
ConnectorTypeDto connectorTypeDto = connectorManager.convertTypeToDto(connectorType);
SysSystemDto systemDto = createSystem(this.getHelper().createName(), connectorTypeDto);
connectorTypeDto.getMetadata().put(MockAdUserConnectorType.SYSTEM_DTO_KEY, systemDto.getId().toString());
connectorTypeDto.setWizardStepName(MockAdUserConnectorType.STEP_CREATE_USER_TEST);
// Execute step for testing permissions to create user.
ConnectorTypeDto stepExecutedResult = connectorManager.execute(connectorTypeDto);
String entityStateId = stepExecutedResult.getMetadata().get(MockAdUserConnectorType.ENTITY_STATE_WITH_TEST_CREATED_USER_DN_KEY);
assertNotNull(entityStateId);
IdmEntityStateDto entityStateDto = entityStateService.get(UUID.fromString(entityStateId));
assertNotNull(entityStateDto);
connectorTypeDto.setWizardStepName(MockAdUserConnectorType.STEP_ASSIGN_GROUP_TEST);
// Execute step for testing permissions to assign user to the group.
connectorManager.execute(connectorTypeDto);
entityStateDto = entityStateService.get(UUID.fromString(entityStateId));
assertNotNull(entityStateDto);
// Clean
entityStateService.delete(entityStateDto);
systemService.delete(systemDto);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto in project CzechIdMng by bcvsolutions.
the class AdUserConnectorTypeTest method testDeleteUser.
@Test
public void testDeleteUser() {
ConnectorType connectorType = connectorManager.getConnectorType(MockAdUserConnectorType.NAME);
ConnectorTypeDto connectorTypeDto = connectorManager.convertTypeToDto(connectorType);
SysSystemDto systemDto = createSystem(this.getHelper().createName(), connectorTypeDto);
connectorTypeDto.getMetadata().put(MockAdUserConnectorType.SYSTEM_DTO_KEY, systemDto.getId().toString());
connectorTypeDto.setWizardStepName(MockAdUserConnectorType.STEP_CREATE_USER_TEST);
// Execute step for testing permissions to create user.
ConnectorTypeDto stepExecutedResult = connectorManager.execute(connectorTypeDto);
String entityStateId = stepExecutedResult.getMetadata().get(MockAdUserConnectorType.ENTITY_STATE_WITH_TEST_CREATED_USER_DN_KEY);
assertNotNull(entityStateId);
IdmEntityStateDto entityStateDto = entityStateService.get(UUID.fromString(entityStateId));
assertNotNull(entityStateDto);
connectorTypeDto.setWizardStepName(MockAdUserConnectorType.STEP_DELETE_USER_TEST);
// Execute step for testing permissions to delete user.
connectorManager.execute(connectorTypeDto);
entityStateDto = entityStateService.get(UUID.fromString(entityStateId));
assertNull(entityStateDto);
// Clean
systemService.delete(systemDto);
}
Aggregations