Search in sources :

Example 26 with IdmEntityStateDto

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);
}
Also used : IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) HashMap(java.util.HashMap) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString)

Example 27 with IdmEntityStateDto

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);
}
Also used : IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) Set(java.util.Set) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) AccUniformPasswordDto(eu.bcvsolutions.idm.acc.dto.AccUniformPasswordDto) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) ResultModel(eu.bcvsolutions.idm.core.api.dto.ResultModel) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)

Example 28 with IdmEntityStateDto

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);
}
Also used : IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) ConnectorTypeDto(eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto) AdGroupConnectorType(eu.bcvsolutions.idm.acc.connector.AdGroupConnectorType) MockAdUserConnectorType(eu.bcvsolutions.idm.acc.service.impl.mock.MockAdUserConnectorType) ConnectorType(eu.bcvsolutions.idm.acc.service.api.ConnectorType) MockAdGroupConnectorType(eu.bcvsolutions.idm.acc.service.impl.mock.MockAdGroupConnectorType) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 29 with IdmEntityStateDto

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);
}
Also used : IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) ConnectorTypeDto(eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto) ConnectorType(eu.bcvsolutions.idm.acc.service.api.ConnectorType) MockAdUserConnectorType(eu.bcvsolutions.idm.acc.service.impl.mock.MockAdUserConnectorType) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 30 with IdmEntityStateDto

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);
}
Also used : IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) ConnectorTypeDto(eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto) ConnectorType(eu.bcvsolutions.idm.acc.service.api.ConnectorType) MockAdUserConnectorType(eu.bcvsolutions.idm.acc.service.impl.mock.MockAdUserConnectorType) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmEntityStateDto (eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto)77 OperationResultDto (eu.bcvsolutions.idm.core.api.dto.OperationResultDto)43 Test (org.junit.Test)41 UUID (java.util.UUID)40 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)33 DefaultResultModel (eu.bcvsolutions.idm.core.api.dto.DefaultResultModel)30 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)30 OperationState (eu.bcvsolutions.idm.core.api.domain.OperationState)24 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)23 List (java.util.List)21 Autowired (org.springframework.beans.factory.annotation.Autowired)21 IdmEntityEventDto (eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto)20 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)19 Transactional (org.springframework.transaction.annotation.Transactional)19 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)18 Lists (com.google.common.collect.Lists)15 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)15 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)15 Assert (org.junit.Assert)14 CoreResultCode (eu.bcvsolutions.idm.core.api.domain.CoreResultCode)13