Search in sources :

Example 56 with IcConnectorObject

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;
}
Also used : IcUidAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcUidAttributeImpl) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcConnectorInstance(eu.bcvsolutions.idm.ic.api.IcConnectorInstance) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 57 with IcConnectorObject

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);
    }
}
Also used : ConnectorType(eu.bcvsolutions.idm.acc.service.api.ConnectorType) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)

Example 58 with IcConnectorObject

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);
}
Also used : SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl)

Example 59 with IcConnectorObject

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;
}
Also used : IcUidAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcUidAttributeImpl) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 60 with IcConnectorObject

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);
}
Also used : AccAccountService(eu.bcvsolutions.idm.acc.service.api.AccAccountService) ResponseEntity(org.springframework.http.ResponseEntity) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)79 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)45 IcAttribute (eu.bcvsolutions.idm.ic.api.IcAttribute)36 IcObjectClass (eu.bcvsolutions.idm.ic.api.IcObjectClass)30 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)28 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)28 Test (org.junit.Test)28 IcConnectorObjectImpl (eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl)27 IcObjectClassImpl (eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl)26 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)23 ProvisioningAttributeDto (eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto)20 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)19 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)19 ProvisioningContext (eu.bcvsolutions.idm.acc.domain.ProvisioningContext)18 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)17 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)17 IcAttributeImpl (eu.bcvsolutions.idm.ic.impl.IcAttributeImpl)17 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)15 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)14 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)13