Search in sources :

Example 21 with AbstractDto

use of eu.bcvsolutions.idm.core.api.dto.AbstractDto in project CzechIdMng by bcvsolutions.

the class DefaultLookupServiceIntegrationTest method testLookupDtoLookupNotExist.

@Test(expected = IllegalArgumentException.class)
public void testLookupDtoLookupNotExist() {
    AbstractDto mockDto = new AbstractDto() {

        private static final long serialVersionUID = 1L;
    };
    // 
    Assert.assertNull(lookupService.lookupDto(mockDto.getClass(), "wrong"));
}
Also used : AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 22 with AbstractDto

use of eu.bcvsolutions.idm.core.api.dto.AbstractDto in project CzechIdMng by bcvsolutions.

the class DefaultLookupServiceIntegrationTest method testLookupEntityLookupNotExist.

@Test(expected = IllegalArgumentException.class)
public void testLookupEntityLookupNotExist() {
    AbstractDto mockDto = new AbstractDto() {

        private static final long serialVersionUID = 1L;
    };
    // 
    Assert.assertNull(lookupService.lookupEntity(mockDto.getClass(), "wrong"));
}
Also used : AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 23 with AbstractDto

use of eu.bcvsolutions.idm.core.api.dto.AbstractDto in project CzechIdMng by bcvsolutions.

the class DefaultEntityEventManagerIntergationTest method testFindOwner.

@Test
@Transactional
public void testFindOwner() {
    IdmIdentityDto owner = getHelper().createIdentity((GuardedString) null);
    // 
    IdmEntityEventDto eventDto = new IdmEntityEventDto();
    eventDto.setOwnerId(owner.getId());
    eventDto.setOwnerType(manager.getOwnerType(owner));
    AbstractDto findOwner = manager.findOwner(eventDto);
    Assert.assertEquals(owner.getId(), findOwner.getId());
    // 
    findOwner = manager.findOwner(manager.getOwnerType(owner), owner.getUsername());
    Assert.assertEquals(owner.getId(), findOwner.getId());
    // 
    findOwner = manager.findOwner(manager.getOwnerType(owner), owner.getId());
    Assert.assertEquals(owner.getId(), findOwner.getId());
}
Also used : AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 24 with AbstractDto

use of eu.bcvsolutions.idm.core.api.dto.AbstractDto in project CzechIdMng by bcvsolutions.

the class PrepareConnectorObjectProcessor method transformPassword.

/**
 * Transform given password with script in attribute mapping.
 */
private GuardedString transformPassword(SysProvisioningOperationDto provisioningOperation, UUID systemId, SysSystemAttributeMappingDto passwordAttribute, GuardedString generatedPassword) {
    if (generatedPassword == null) {
        return null;
    }
    String uid = provisioningOperation.getSystemEntityUid();
    UUID entityIdentifier = provisioningOperation.getEntityIdentifier();
    AbstractDto abstractDto = null;
    if (entityIdentifier != null) {
        BaseDto dto = lookupService.lookupDto(provisioningOperation.getEntityType().getEntityType(), entityIdentifier);
        if (dto instanceof AbstractDto) {
            abstractDto = (AbstractDto) dto;
        } else {
            LOG.warn("Dto with id [{}] hasn't type [{}]. Current type: [{}]. Into script will be send null as entity.", entityIdentifier, AbstractDto.class.getName(), dto == null ? null : dto.getClass());
        }
    } else {
        LOG.warn("Entity identifier for uid [{}] is null. Provisioning is probably called directly. Into password transfomartion will not be sent entity.", uid);
    }
    // transformed password
    Object transformValue = attributeMappingService.transformValueToResource(uid, generatedPassword, passwordAttribute, abstractDto);
    if (transformValue == null) {
        return null;
    } else if (transformValue instanceof GuardedString) {
        return (GuardedString) transformValue;
    }
    throw new ResultCodeException(AccResultCode.PROVISIONING_PASSWORD_TRANSFORMATION_FAILED, ImmutableMap.of("uid", uid, "mappedAttribute", passwordAttribute.getName()));
}
Also used : AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) UUID(java.util.UUID)

Example 25 with AbstractDto

use of eu.bcvsolutions.idm.core.api.dto.AbstractDto in project CzechIdMng by bcvsolutions.

the class IdmEntityStateController method toFilter.

@Override
protected IdmEntityStateFilter toFilter(MultiValueMap<String, Object> parameters) {
    IdmEntityStateFilter filter = new IdmEntityStateFilter(parameters, getParameterConverter());
    // 
    // owner decorator
    String ownerId = getParameterConverter().toString(parameters, IdmEntityStateFilter.PARAMETER_OWNER_ID);
    UUID ownerUuid = null;
    if (StringUtils.isNotEmpty(filter.getOwnerType()) && StringUtils.isNotEmpty(ownerId)) {
        // try to find entity owner by Codeable identifier
        AbstractDto owner = manager.findOwner(filter.getOwnerType(), ownerId);
        if (owner != null) {
            ownerUuid = owner.getId();
        } else {
            LOG.debug("Entity type [{}] with identifier [{}] does not found, raw ownerId will be used as uuid.", filter.getOwnerType(), ownerId);
            // Better exception for FE.
            try {
                DtoUtils.toUuid(ownerId);
            } catch (ClassCastException ex) {
                throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", ownerId), ex);
            }
        }
    }
    if (ownerUuid == null) {
        ownerUuid = getParameterConverter().toUuid(parameters, "ownerId");
    }
    filter.setOwnerId(ownerUuid);
    // 
    return filter;
}
Also used : AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IdmEntityStateFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityStateFilter) UUID(java.util.UUID)

Aggregations

AbstractDto (eu.bcvsolutions.idm.core.api.dto.AbstractDto)54 UUID (java.util.UUID)28 Test (org.junit.Test)16 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)15 BaseDto (eu.bcvsolutions.idm.core.api.dto.BaseDto)13 HashMap (java.util.HashMap)12 List (java.util.List)11 Autowired (org.springframework.beans.factory.annotation.Autowired)11 Transactional (org.springframework.transaction.annotation.Transactional)11 Assert (org.springframework.util.Assert)11 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)10 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)10 Map (java.util.Map)10 Service (org.springframework.stereotype.Service)10 Embedded (eu.bcvsolutions.idm.core.api.domain.Embedded)9 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)9 IntrospectionException (java.beans.IntrospectionException)9 Field (java.lang.reflect.Field)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 ImmutableMap (com.google.common.collect.ImmutableMap)8