use of eu.bcvsolutions.idm.core.api.dto.filter.IdmConceptRoleRequestFilter in project CzechIdMng by bcvsolutions.
the class IdmConceptRoleRequestController method toFilter.
@Override
protected IdmConceptRoleRequestFilter toFilter(MultiValueMap<String, Object> parameters) {
IdmConceptRoleRequestFilter filter = new IdmConceptRoleRequestFilter();
filter.setText(getParameterConverter().toString(parameters, "text"));
filter.setRoleRequestId(getParameterConverter().toUuid(parameters, "roleRequestId"));
filter.setState(getParameterConverter().toEnum(parameters, "state", RoleRequestState.class));
return filter;
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmConceptRoleRequestFilter in project CzechIdMng by bcvsolutions.
the class IdentitySynchronizationExecutor method createEntityAccount.
@Override
protected EntityAccountDto createEntityAccount(AccAccountDto account, IdmIdentityDto entity, SynchronizationContext context) {
Assert.notNull(account);
Assert.notNull(entity);
EntityAccountDto entityAccount = super.createEntityAccount(account, entity, context);
Assert.isInstanceOf(AccIdentityAccountDto.class, entityAccount, "For identity sync must be entity-account relation instance of AccIdentityAccountDto!");
AccIdentityAccountDto identityAccount = (AccIdentityAccountDto) entityAccount;
SysSyncIdentityConfigDto config = this.getConfig(context);
UUID defaultRoleId = config.getDefaultRole();
if (defaultRoleId == null) {
return identityAccount;
}
// Default role is defines
IdmRoleDto defaultRole = DtoUtils.getEmbedded(config, SysSyncIdentityConfig_.defaultRole, IdmRoleDto.class);
context.getLogItem().addToLog(MessageFormat.format("Default role [{1}] is defines and will be assigned to the identity [{0}].", entity.getCode(), defaultRole.getCode()));
Assert.notNull(defaultRole, "Default role must be found for this sync configuration!");
IdmIdentityContractDto primeContract = identityContractService.getPrimeValidContract(entity.getId());
if (primeContract == null) {
context.getLogItem().addToLog("Warning! - Default role is set, but could not be assigned to identity, because was not found any valid identity contract!");
this.initSyncActionLog(context.getActionType(), OperationResultType.WARNING, context.getLogItem(), context.getLog(), context.getActionLogs());
return identityAccount;
}
// Create role request for default role and primary contract
IdmRoleRequestDto roleRequest = roleRequestService.createRequest(primeContract, defaultRole);
roleRequest = roleRequestService.startRequestInternal(roleRequest.getId(), false);
// Load concept (can be only one)
IdmConceptRoleRequestFilter conceptFilter = new IdmConceptRoleRequestFilter();
conceptFilter.setRoleRequestId(roleRequest.getId());
UUID identityRoleId = conceptRoleRequestService.find(conceptFilter, null).getContent().get(0).getIdentityRole();
Assert.notNull(identityRoleId, "Identity role relation had to been created!");
identityAccount.setIdentityRole(identityRoleId);
AccIdentityAccountDto duplicate = this.findDuplicate(identityAccount);
if (duplicate != null) {
// This IdentityAccount is new and duplicated, we do not want create duplicated
// relation.
// Same IdentityAccount had to be created by assigned default role!
context.getLogItem().addToLog(MessageFormat.format("This identity-account (identity-role id: {2}) is new and duplicated, " + "we do not want create duplicated relation! " + "We will reusing already persisted identity-account [{3}]. " + "Probable reason: Same identity-account had to be created by assigned default role!", identityAccount.getAccount(), identityAccount.getIdentity(), identityAccount.getIdentityRole(), duplicate.getId()));
// Reusing duplicate
return duplicate;
}
return identityAccount;
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmConceptRoleRequestFilter in project CzechIdMng by bcvsolutions.
the class SelfRoleRequestEvaluatorIntegrationTest method testCanReadSelfRoleRequest.
@Test
public void testCanReadSelfRoleRequest() {
IdmRoleDto role = roleService.getByCode(InitDemoData.DEFAULT_ROLE_NAME);
// prepare identity
IdmIdentityDto identity = helper.createIdentity();
// assign role request
IdmRoleRequestDto roleRequest = helper.assignRoles(helper.getPrimeContract(identity.getId()), role);
//
try {
loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
//
IdmRoleRequestDto read = roleRequestService.get(roleRequest.getId(), IdmBasePermission.READ);
assertEquals(roleRequest, read);
//
IdmConceptRoleRequestFilter filter = new IdmConceptRoleRequestFilter();
filter.setRoleRequestId(roleRequest.getId());
Page<IdmConceptRoleRequestDto> concepts = conceptRoleRequestController.find(filter, null, IdmBasePermission.READ);
assertEquals(1, concepts.getTotalElements());
} finally {
logout();
}
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmConceptRoleRequestFilter in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityServiceIntegrationTest method testReferentialRoleRequestIntegrity.
@Test
public void testReferentialRoleRequestIntegrity() {
IdmIdentityDto identity = helper.createIdentity();
String username = identity.getUsername();
// role with guarantee
IdmRoleDto role = new IdmRoleDto();
String roleName = "test_r_" + System.currentTimeMillis();
role.setName(roleName);
role = roleService.save(role);
// assigned role
IdmRoleRequestDto request = helper.assignRoles(helper.getPrimeContract(identity.getId()), false, role);
IdmConceptRoleRequestFilter conceptFilter = new IdmConceptRoleRequestFilter();
conceptFilter.setRoleRequestId(request.getId());
IdmIdentityRoleFilter identityRolefilter = new IdmIdentityRoleFilter();
identityRolefilter.setIdentityId(identity.getId());
assertNotNull(identityService.getByUsername(username));
assertEquals(1, identityRoleService.find(identityRolefilter, null).getTotalElements());
assertEquals(1, conceptRequestService.find(conceptFilter, null).getTotalElements());
IdmConceptRoleRequestDto concept = conceptRequestService.find(conceptFilter, null).getContent().get(0);
concept.setWfProcessId("test_wf_" + System.currentTimeMillis());
conceptRequestService.save(concept);
//
identityService.delete(identity);
role = roleService.get(role.getId());
//
assertNull(identityService.getByUsername(username));
assertNull(passwordService.findOneByIdentity(identity.getId()));
assertEquals(0, identityContractService.findAllByIdentity(identity.getId()).size());
assertEquals(0, identityRoleService.find(identityRolefilter, null).getTotalElements());
assertEquals(0, conceptRequestService.find(conceptFilter, null).getTotalElements());
roleService.delete(role);
assertNull(roleService.get(role.getId()));
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmConceptRoleRequestFilter in project CzechIdMng by bcvsolutions.
the class IdmRoleRequestController method getConcepts.
@ResponseBody
@RequestMapping(value = "/{backendId}/concepts", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.ROLE_REQUEST_READ + "')")
@ApiOperation(value = "Role request concepts", nickname = "getRoleRequestConcepts", tags = { IdmRoleRequestController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.ROLE_REQUEST_READ, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.ROLE_REQUEST_READ, description = "") }) })
@ApiImplicitParams({ @ApiImplicitParam(name = "parameters", allowMultiple = true, dataType = "string", paramType = "query", value = "Search criteria parameters. Parameters could be registered by module. Example id=25c5b9e8-b15d-4f95-b715-c7edf6f4aee6"), @ApiImplicitParam(name = "page", dataType = "string", paramType = "query", value = "Results page you want to retrieve (0..N)"), @ApiImplicitParam(name = "size", dataType = "string", paramType = "query", value = "Number of records per page."), @ApiImplicitParam(name = "sort", allowMultiple = true, dataType = "string", paramType = "query", value = "Sorting criteria in the format: property(,asc|desc). " + "Default sort order is ascending. " + "Multiple sort criteria are supported.") })
public Resources<?> getConcepts(@ApiParam(value = "Role request's uuid identifier.", required = true) @PathVariable String backendId, @RequestParam(required = false) MultiValueMap<String, Object> parameters, @PageableDefault Pageable pageable) {
IdmRoleRequestDto entity = getDto(backendId);
if (entity == null) {
throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
}
//
IdmConceptRoleRequestFilter filter = conceptRoleRequestController.toFilter(parameters);
filter.setRoleRequestId(entity.getId());
//
return toResources(conceptRoleRequestController.find(filter, pageable, IdmBasePermission.READ), IdmRoleRequestDto.class);
}
Aggregations