use of eu.bcvsolutions.idm.ic.api.IcConnectorObject in project CzechIdMng by bcvsolutions.
the class ProvisioningDeleteProcessor method processInternal.
@Override
public IcUidAttribute processInternal(SysProvisioningOperationDto provisioningOperation, IcConnectorConfiguration connectorConfig) {
SysSystemDto system = systemService.get(provisioningOperation.getSystem());
IcConnectorInstance connectorInstance = systemService.getConnectorInstance(system);
String uid = provisioningOperationService.getByProvisioningOperation(provisioningOperation).getUid();
IcUidAttribute uidAttribute = new IcUidAttributeImpl(null, uid, null);
IcObjectClass objectClass = provisioningOperation.getProvisioningContext().getConnectorObject().getObjectClass();
//
IcConnectorObject connectorObject = connectorFacade.readObject(connectorInstance, connectorConfig, objectClass, uidAttribute);
if (connectorObject != null) {
connectorFacade.deleteObject(connectorInstance, connectorConfig, objectClass, uidAttribute);
}
return null;
}
use of eu.bcvsolutions.idm.ic.api.IcConnectorObject in project CzechIdMng by bcvsolutions.
the class PrepareConnectorObjectProcessor method process.
/**
* Prepare provisioning operation execution
*/
@Override
public EventResult<SysProvisioningOperationDto> process(EntityEvent<SysProvisioningOperationDto> event) {
SysProvisioningOperationDto provisioningOperation = event.getContent();
SysSystemDto system = systemService.get(provisioningOperation.getSystem());
IcObjectClass objectClass = provisioningOperation.getProvisioningContext().getConnectorObject().getObjectClass();
SysSystemEntityDto systemEntity = provisioningOperationService.getByProvisioningOperation(provisioningOperation);
String uid = systemEntity.getUid();
boolean isWish = systemEntity.isWish();
LOG.debug("Start preparing attribubes for provisioning operation [{}] for object with uid [{}] and connector object [{}]", provisioningOperation.getOperationType(), uid, objectClass.getType());
// Find connector identification persisted in system
if (system.getConnectorKey() == null) {
throw new ProvisioningException(AccResultCode.CONNECTOR_KEY_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
}
try {
IcConnectorObject existsConnectorObject = null;
// We do not want search account on the target system, when this is the first
// call the connector and auto mapping is not allowed.
ConnectorType connectorType = connectorManager.findConnectorTypeBySystem(system);
if (!isWish || provisioningConfiguration.isAllowedAutoMappingOnExistingAccount()) {
existsConnectorObject = connectorType.readConnectorObject(system, uid, objectClass);
}
if (existsConnectorObject == null) {
processCreate(provisioningOperation);
} else {
processUpdate(provisioningOperation, existsConnectorObject, connectorType);
// prepare attributes on target system for FE view
ProvisioningContext context = provisioningOperation.getProvisioningContext();
IcConnectorObject systemAttrs = intersectAccountAndSystemAttrs(context.getAccountObject(), existsConnectorObject);
context.setSystemConnectorObject(systemAttrs);
if (!provisioningOperation.isDryRun()) {
provisioningOperation = provisioningOperationService.saveOperation(provisioningOperation);
}
}
//
LOG.debug("Preparing attribubes for provisioning operation [{}] for object with uid [{}] and connector object [{}] is sucessfully completed", provisioningOperation.getOperationType(), uid, objectClass.getType());
if (!provisioningOperation.isDryRun()) {
// set back to event content
provisioningOperation = provisioningOperationService.saveOperation(provisioningOperation);
// log attributes used in provisioning context into provisioning attributes
provisioningAttributeService.saveAttributes(provisioningOperation);
}
event.setContent(provisioningOperation);
return new DefaultEventResult<>(event, this);
} catch (Exception ex) {
if (!provisioningOperation.isDryRun()) {
provisioningOperation = provisioningOperationService.handleFailed(provisioningOperation, ex);
}
// TODO nastavit vyjimku stav do provisioning operation podobne jak se deje v handleFailed
event.setContent(provisioningOperation);
return new DefaultEventResult<>(event, this, true);
}
}
use of eu.bcvsolutions.idm.ic.api.IcConnectorObject in project CzechIdMng by bcvsolutions.
the class PrepareConnectorObjectProcessor method processUpdate.
private void processUpdate(SysProvisioningOperationDto provisioningOperation, IcConnectorObject existsConnectorObject, ConnectorType connectorType) {
SysSystemDto system = systemService.get(provisioningOperation.getSystem());
String systemEntityUid = provisioningOperationService.getByProvisioningOperation(provisioningOperation).getUid();
ProvisioningContext provisioningContext = provisioningOperation.getProvisioningContext();
IcConnectorObject connectorObject = provisioningContext.getConnectorObject();
IcObjectClass objectClass = connectorObject.getObjectClass();
//
IcConnectorObject updateConnectorObject;
if (provisioningContext.getAccountObject() == null) {
updateConnectorObject = connectorObject;
} else {
Map<ProvisioningAttributeDto, Object> fullAccountObject = provisioningOperationService.getFullAccountObject(provisioningOperation);
updateConnectorObject = new IcConnectorObjectImpl(systemEntityUid, objectClass, null);
SysSystemMappingDto mapping = getMapping(system, provisioningOperation.getEntityType());
SysSchemaObjectClassDto schemaObjectClassDto = schemaObjectClassService.get(mapping.getObjectClass());
List<SysSchemaAttributeDto> schemaAttributes = findSchemaAttributes(system, schemaObjectClassDto);
for (Entry<ProvisioningAttributeDto, Object> entry : fullAccountObject.entrySet()) {
ProvisioningAttributeDto provisioningAttribute = entry.getKey();
// Resolve update for given attribute
processUpdateByAttribute(provisioningAttribute, provisioningOperation, existsConnectorObject, system, systemEntityUid, updateConnectorObject, fullAccountObject, schemaAttributes, connectorType);
}
}
//
provisioningOperation.getProvisioningContext().setConnectorObject(updateConnectorObject);
provisioningOperation.setOperationType(ProvisioningEventType.UPDATE);
}
use of eu.bcvsolutions.idm.ic.api.IcConnectorObject in project CzechIdMng by bcvsolutions.
the class ProvisioningUpdateProcessor method processInternal.
@Override
public IcUidAttribute processInternal(SysProvisioningOperationDto provisioningOperation, IcConnectorConfiguration connectorConfig) {
String uid = provisioningOperationService.getByProvisioningOperation(provisioningOperation).getUid();
IcUidAttribute uidAttribute = new IcUidAttributeImpl(null, uid, null);
IcConnectorObject connectorObject = provisioningOperation.getProvisioningContext().getConnectorObject();
if (!connectorObject.getAttributes().isEmpty()) {
SysSystemDto system = systemService.get(provisioningOperation.getSystem());
//
// Transform last guarded string into classic string
List<IcAttribute> transformedIcAttributes = transformGuardedStringToString(provisioningOperation, connectorObject.getAttributes());
return connectorFacade.updateObject(systemService.getConnectorInstance(system), connectorConfig, connectorObject.getObjectClass(), uidAttribute, transformedIcAttributes);
} else {
// TODO: appropriate message - provisioning is not executed - attributes don't change
// Operation was logged only. Provisioning was not executed, because attributes doesn't change.
}
return null;
}
use of eu.bcvsolutions.idm.ic.api.IcConnectorObject in project CzechIdMng by bcvsolutions.
the class AccAccountController method getConnectorObject.
@ResponseBody
@PreAuthorize("hasAuthority('" + AccGroupPermission.SYSTEM_READ + "')")
@RequestMapping(value = "/{backendId}/connector-object", method = RequestMethod.GET)
@ApiOperation(value = "Connector object for the account. Contains only attributes for witch have a schema attribute definitons.", 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 = "Account's uuid identifier.", required = true) @PathVariable @NotNull String backendId) {
AccAccountDto account = this.getDto(backendId);
if (account == null) {
throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
}
IcConnectorObject connectorObject = ((AccAccountService) getService()).getConnectorObject(account, IdmBasePermission.READ);
if (connectorObject == null) {
return new ResponseEntity<IcConnectorObject>(HttpStatus.NO_CONTENT);
}
return new ResponseEntity<IcConnectorObject>(connectorObject, HttpStatus.OK);
}
Aggregations