use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class SysSystemEntityController method getConnectorObject.
@ResponseBody
@PreAuthorize("hasAuthority('" + AccGroupPermission.SYSTEM_READ + "')")
@RequestMapping(value = "/{backendId}/connector-object", method = RequestMethod.GET)
@ApiOperation(value = "Connector object for the system entity", nickname = "getConnectorObject", response = IcConnectorObject.class, tags = { SysSystemEntityController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = AccGroupPermission.SYSTEM_READ, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = AccGroupPermission.SYSTEM_READ, description = "") }) })
public ResponseEntity<IcConnectorObject> getConnectorObject(@ApiParam(value = "System entity's uuid identifier.", required = true) @PathVariable @NotNull String backendId) {
SysSystemEntityDto systemEntity = this.getDto(backendId);
if (systemEntity == null) {
throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
}
IcConnectorObject connectorObject = ((SysSystemEntityService) getService()).getConnectorObject(systemEntity, IdmBasePermission.READ);
if (connectorObject == null) {
return new ResponseEntity<IcConnectorObject>(HttpStatus.NO_CONTENT);
}
return new ResponseEntity<IcConnectorObject>(connectorObject, HttpStatus.OK);
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class DefaultProvisioningService method doProvisioning.
@Override
public void doProvisioning(AccAccountDto account) {
Assert.notNull(account, "Account is required.");
SysSystemEntityDto systemEntityDto = systemEntityService.get(account.getSystemEntity());
this.getExecutor(systemEntityDto.getEntityType()).doProvisioning(account);
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class AbstractSynchronizationExecutor method findAccount.
private AccAccountDto findAccount(SynchronizationContext context) {
String uid = context.getUid();
SysSystemDto system = context.getSystem();
SysSyncItemLogDto logItem = context.getLogItem();
SysSystemEntityDto systemEntity = context.getSystemEntity();
AccAccountFilter accountFilter = new AccAccountFilter();
accountFilter.setSystemId(system.getId());
List<AccAccountDto> accounts = null;
if (systemEntity != null) {
// System entity for this uid was found. We will find account
// for this system entity.
addToItemLog(logItem, MessageFormat.format("System entity [{1}] for this UID [{0}] was found. We try to find account for this system entity", uid, systemEntity.getId()));
accountFilter.setSystemEntityId(systemEntity.getId());
accounts = accountService.find(accountFilter, null).getContent();
}
if (CollectionUtils.isEmpty(accounts)) {
// System entity was not found. We will find account by generated UID directly.
// Generate UID value from mapped attribute marked as UID (Unique ID).
// UID mapped attribute must exist and returned value must be not null
// and must be String
String attributeUid = this.generateUID(context);
addToItemLog(logItem, MessageFormat.format("Account was not found. We try to find account for UID [{0}] (generated from the mapped attribute marked as Identifier)", attributeUid));
accountFilter.setUid(attributeUid);
accountFilter.setSystemEntityId(null);
accounts = accountService.find(accountFilter, null).getContent();
}
if (accounts != null && accounts.size() > 1) {
throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_TO_MANY_ACC_ACCOUNT, uid);
}
if (accounts != null && !accounts.isEmpty()) {
return accounts.get(0);
}
return null;
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningArchiveService method archive.
@Override
// we want log in archive always
@Transactional(propagation = Propagation.REQUIRES_NEW)
public SysProvisioningArchiveDto archive(SysProvisioningOperationDto provisioningOperation) {
Builder builder = new SysProvisioningArchiveDto.Builder(provisioningOperation);
if (provisioningOperation.getSystemEntity() != null) {
SysSystemEntityDto systemEntity = DtoUtils.getEmbedded(provisioningOperation, SysProvisioningOperation_.systemEntity, (SysSystemEntityDto) null);
if (systemEntity == null) {
systemEntity = systemEntityService.get(provisioningOperation.getSystemEntity());
}
builder.setSystemEntityUid(systemEntity.getUid());
}
//
SysProvisioningArchiveDto archive = builder.build();
// preserve original operation creator
archive.setCreator(provisioningOperation.getCreator());
archive.setCreatorId(provisioningOperation.getCreatorId());
archive.setOriginalCreator(provisioningOperation.getOriginalCreator());
archive.setOriginalCreatorId(provisioningOperation.getOriginalCreatorId());
// preserve original created => operation was created
archive.setCreated(provisioningOperation.getCreated());
// archive modified is used as the executed / canceled
archive.setModified(ZonedDateTime.now());
// archive relation on the role-request
archive.setRoleRequestId(provisioningOperation.getRoleRequestId());
//
archive = save(archive);
//
// log attributes used in provisioning context into provisioning attributes
provisioningAttributeService.saveAttributes(archive);
//
return archive;
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class DefaultSynchronizationService method resolveUnlinkedSituation.
@Override
public SysSyncItemLogDto resolveUnlinkedSituation(String uid, SystemEntityType entityType, UUID entityId, UUID configId, String actionType, List<IcAttribute> icAttributes) {
Assert.notNull(uid, "Uid is required.");
Assert.notNull(entityType, "Entity type is required.");
Assert.notNull(configId, "Configuration identifier is required.");
Assert.notNull(actionType, "Action type is required.");
Assert.notNull(entityId, "Entity identifier is required.");
AbstractSysSyncConfigDto config = synchronizationConfigService.get(configId);
SysSystemMappingDto mapping = systemMappingService.get(config.getSystemMapping());
SysSchemaObjectClassDto sysSchemaObjectClassDto = schemaObjectClassService.get(mapping.getObjectClass());
SysSystemDto system = DtoUtils.getEmbedded(sysSchemaObjectClassDto, SysSchemaObjectClass_.system);
SysSystemEntityDto systemEntity = findSystemEntity(uid, system, entityType);
SysSyncItemLogDto itemLog = new SysSyncItemLogDto();
SysSystemAttributeMappingFilter attributeHandlingFilter = new SysSystemAttributeMappingFilter();
attributeHandlingFilter.setSystemMappingId(mapping.getId());
List<SysSystemAttributeMappingDto> mappedAttributes = attributeHandlingService.find(attributeHandlingFilter, null).getContent();
// Little workaround, we have only IcAttributes ... we create IcObject manually
IcConnectorObjectImpl icObject = new IcConnectorObjectImpl();
icObject.setAttributes(icAttributes);
icObject.setUidValue(uid);
SynchronizationContext context = new SynchronizationContext();
//
context.addUid(uid).addSystem(//
system).addConfig(//
config).addEntityType(//
entityType).addEntityId(//
entityId).addLogItem(//
itemLog).addSystemEntity(//
systemEntity).addIcObject(//
icObject).addMappedAttributes(//
mappedAttributes);
getSyncExecutor(entityType, configId).resolveUnlinkedSituation(SynchronizationUnlinkedActionType.valueOf(actionType), context);
return itemLog;
}
Aggregations