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"));
}
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"));
}
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());
}
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()));
}
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;
}
Aggregations