use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleRequestService method createRequest.
@Override
public IdmRoleRequestDto createRequest(IdmIdentityContractDto contract, IdmRoleDto... roles) {
Assert.notNull(contract, "Contract must be filled for create role request!");
IdmRoleRequestDto roleRequest = new IdmRoleRequestDto();
roleRequest.setApplicant(contract.getIdentity());
roleRequest.setRequestedByType(RoleRequestedByType.AUTOMATICALLY);
roleRequest.setExecuteImmediately(true);
roleRequest = this.save(roleRequest);
if (roles != null) {
for (IdmRoleDto role : roles) {
createConcept(roleRequest, contract, role.getId(), ConceptRoleRequestOperation.ADD);
}
}
return roleRequest;
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class RoleSynchronizationExecutor method doUpdateAccount.
/**
* Call provisioning for given account
*
* @param account
* @param entityType
* @param log
* @param logItem
* @param actionLogs
*/
protected void doUpdateAccount(AccAccountDto account, SystemEntityType entityType, SysSyncLogDto log, SysSyncItemLogDto logItem, List<SysSyncActionLogDto> actionLogs) {
UUID entityId = getEntityByAccount(account.getId());
IdmRoleDto entity = null;
if (entityId != null) {
entity = roleService.get(entityId);
}
if (entity == null) {
addToItemLog(logItem, "Entity account relation (with ownership = true) was not found!");
initSyncActionLog(SynchronizationActionType.UPDATE_ENTITY, OperationResultType.WARNING, logItem, log, actionLogs);
return;
}
// Call provisioning for this entity
callProvisioningForEntity(entity, entityType, logItem);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class AsynchronousAccountManagementIntegrationTest method testAsynchronousAccountManagementError.
@Test
public void testAsynchronousAccountManagementError() {
// add error to some script
SysSystemDto system = helper.createTestResourceSystem(true);
SysSystemMappingDto mapping = helper.getDefaultMapping(system);
SysSystemAttributeMappingDto attributeHandlingUserName = schemaAttributeHandlingService.findBySystemMappingAndName(mapping.getId(), TestHelper.ATTRIBUTE_MAPPING_NAME);
// username is transformed with error
attributeHandlingUserName.setTransformToResourceScript("returan \"" + "error" + "\";");
attributeHandlingUserName = schemaAttributeHandlingService.save(attributeHandlingUserName);
IdmIdentityDto identity = helper.createIdentity();
IdmRoleDto role = helper.createRole();
helper.createRoleSystem(role, system);
IdmIdentityRoleDto identityRole = helper.createIdentityRole(identity, role);
try {
helper.waitForResult(res -> {
return !(entityEventService.findByState(configurationService.getInstanceId(), OperationState.CREATED).isEmpty() && entityEventService.findByState(configurationService.getInstanceId(), OperationState.RUNNING).isEmpty());
});
AccAccountDto account = accountService.getAccount(identity.getUsername(), system.getId());
Assert.assertNull(account);
//
// find event result with exception
IdmEntityEventFilter eventFilter = new IdmEntityEventFilter();
eventFilter.setOwnerId(identityRole.getId());
eventFilter.setStates(Lists.newArrayList(OperationState.EXCEPTION));
List<IdmEntityEventDto> failedEvents = entityEventService.find(eventFilter, null).getContent();
//
Assert.assertEquals(1, failedEvents.size());
Assert.assertEquals(CoreResultCode.GROOVY_SCRIPT_EXCEPTION.getCode(), failedEvents.get(0).getResult().getCode());
} finally {
identityService.delete(identity);
systemService.delete(system);
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class AsynchronousAccountManagementIntegrationTest method testAsynchronousAccountManagementGreenLine.
@Test
public void testAsynchronousAccountManagementGreenLine() {
IdmIdentityDto identity = helper.createIdentity();
SysSystemDto system = helper.createTestResourceSystem(true);
IdmRoleDto role = helper.createRole();
helper.createRoleSystem(role, system);
helper.createIdentityRole(identity, role);
try {
helper.waitForResult(res -> {
return !(entityEventService.findByState(configurationService.getInstanceId(), OperationState.CREATED).isEmpty() && entityEventService.findByState(configurationService.getInstanceId(), OperationState.RUNNING).isEmpty());
});
AccAccountDto account = accountService.getAccount(identity.getUsername(), system.getId());
Assert.assertNotNull(account);
Assert.assertNotNull(helper.findResource(account.getRealUid()));
} finally {
identityService.delete(identity);
systemService.delete(system);
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class IdentitySetPasswordProcessorIntegrationTest method testGeneratePassword.
@Test
public void testGeneratePassword() {
SysSystemDto system = helper.createTestResourceSystem(true);
//
IdmRoleDto role = helper.createRole();
helper.createRoleSystem(role, system);
IdmIdentityDto identity = helper.createIdentity();
IdmIdentityContractDto contract = helper.getPrimeContract(identity.getId());
contract.setValidFrom(new LocalDate().plusDays(1));
identityContractService.save(contract);
identity = identityService.get(identity.getId());
Assert.assertEquals(IdentityState.FUTURE_CONTRACT, identity.getState());
helper.createIdentityRole(identity, role);
//
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
AccIdentityAccountDto accountIdentityOne = identityAccountService.find(filter, null).getContent().get(0);
AccAccountDto account = accountService.get(accountIdentityOne.getAccount());
// Create new password one
PasswordChangeDto passwordChange = new PasswordChangeDto();
passwordChange.setAccounts(ImmutableList.of(account.getId().toString()));
passwordChange.setNewPassword(new GuardedString(IDENTITY_PASSWORD_ONE));
passwordChange.setIdm(true);
//
// Do change of password for selected accounts
identityService.passwordChange(identity, passwordChange);
//
// Check correct password One
TestResource resource = helper.findResource(account.getRealUid());
Assert.assertNotNull(resource);
Assert.assertEquals(IDENTITY_PASSWORD_ONE, resource.getPassword());
//
// set contract to valid
contract.setValidFrom(new LocalDate());
identityContractService.save(contract);
identity = identityService.get(identity.getId());
Assert.assertEquals(IdentityState.VALID, identity.getState());
//
// check password on target system was changed
resource = helper.findResource(account.getRealUid());
Assert.assertNotNull(resource);
Assert.assertNotEquals(IDENTITY_PASSWORD_ONE, resource.getPassword());
}
Aggregations