Search in sources :

Example 1 with IcConnectorInfo

use of eu.bcvsolutions.idm.ic.api.IcConnectorInfo in project CzechIdMng by bcvsolutions.

the class BasicVirtualConnector method init.

@Override
public void init(IcConnectorConfiguration configuration) {
    Assert.notNull(configuration);
    this.configuration = configuration;
    if (!(configuration instanceof IcConnectorConfigurationCzechIdMImpl)) {
        throw new IcException(MessageFormat.format("Connector configuration for virtual system must be instance of [{0}]", IcConnectorConfigurationCzechIdMImpl.class.getName()));
    }
    systemId = ((IcConnectorConfigurationCzechIdMImpl) configuration).getSystemId();
    if (systemId == null) {
        throw new IcException("System ID cannot be null (for virtual system)");
    }
    SysSystemDto system = this.systemService.get(systemId);
    if (system == null) {
        throw new IcException("System cannot be null (for virtual system)");
    }
    // TODO: This is workaround how mark SysSystem as virtual
    if (!system.isVirtual()) {
        system.setVirtual(true);
        system = this.systemService.save(system);
    }
    IcConnectorClass connectorAnnotation = this.getClass().getAnnotation(IcConnectorClass.class);
    IcConnectorInfo info = CzechIdMIcConvertUtil.convertConnectorClass(connectorAnnotation, this.getClass());
    // Load configuration object
    virtualConfiguration = (BasicVirtualConfiguration) CzechIdMIcConvertUtil.convertIcConnectorConfiguration(configuration, connectorAnnotation.configurationClass());
    // Validate configuration
    virtualConfiguration.validate();
    connectorKey = info.getConnectorKey().getFullName();
    String virtualSystemKey = MessageFormat.format("{0}:systemId={1}", connectorKey, systemId.toString());
    String type = VsAccount.class.getName();
    // Create/Update form definition and attributes
    formDefinition = updateFormDefinition(virtualSystemKey, type, system, virtualConfiguration);
    // Update identity and role implementers relations
    updateSystemImplementers(this.virtualConfiguration, this.systemId);
}
Also used : IcConnectorInfo(eu.bcvsolutions.idm.ic.api.IcConnectorInfo) IcConnectorConfigurationCzechIdMImpl(eu.bcvsolutions.idm.ic.czechidm.domain.IcConnectorConfigurationCzechIdMImpl) IcException(eu.bcvsolutions.idm.ic.exception.IcException) IcConnectorClass(eu.bcvsolutions.idm.ic.api.annotation.IcConnectorClass) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 2 with IcConnectorInfo

use of eu.bcvsolutions.idm.ic.api.IcConnectorInfo in project CzechIdMng by bcvsolutions.

the class DefaultVsRequestService method getVirtualConnector.

/**
 * Get virtual connector by vs request
 *
 * @param request
 * @return
 */
private VsVirtualConnector getVirtualConnector(VsRequestDto request) {
    IcConnectorInfo connectorInfo = // 
    czechIdMConfigurationService.getAvailableLocalConnectors().stream().filter(// 
    info -> request.getConnectorKey().equals(info.getConnectorKey().getFullName())).findFirst().orElse(null);
    if (connectorInfo == null) {
        throw new IcException(MessageFormat.format("We cannot found connector info by connector key [{0}] from virtual system request!", request.getConnectorKey()));
    }
    IcConnectorInstance connectorKeyInstance = new IcConnectorInstanceImpl(null, connectorInfo.getConnectorKey(), false);
    IcConnector connectorInstance = czechIdMConnectorService.getConnectorInstance(connectorKeyInstance, request.getConfiguration());
    if (!(connectorInstance instanceof VsVirtualConnector)) {
        throw new IcException("Found connector instance is not virtual system connector!");
    }
    VsVirtualConnector virtualConnector = (VsVirtualConnector) connectorInstance;
    return virtualConnector;
}
Also used : IcConnectorInfo(eu.bcvsolutions.idm.ic.api.IcConnectorInfo) IcConnectorInstance(eu.bcvsolutions.idm.ic.api.IcConnectorInstance) IcConnectorInstanceImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorInstanceImpl) IcException(eu.bcvsolutions.idm.ic.exception.IcException) IcConnector(eu.bcvsolutions.idm.ic.api.IcConnector) VsVirtualConnector(eu.bcvsolutions.idm.vs.connector.api.VsVirtualConnector)

Example 3 with IcConnectorInfo

use of eu.bcvsolutions.idm.ic.api.IcConnectorInfo in project CzechIdMng by bcvsolutions.

the class DefaultVsSystemService method create.

@Override
public SysSystemDto create(VsSystemDto vsSystem) {
    Assert.notNull(vsSystem, "Vs system dto cannot be null (for create new virtual system)");
    Assert.notNull(vsSystem.getName(), "Vs system name cannot be null (for create new virtual system)");
    LOG.info("Create new virtual system with name [{}].", vsSystem.getName());
    SysSystemDto system = new SysSystemDto();
    // Find connector for VS
    Class<? extends VsVirtualConnector> defaultVirtualConnector = BasicVirtualConnector.class;
    IcConnectorClass connectorAnnotation = defaultVirtualConnector.getAnnotation(IcConnectorClass.class);
    IcConnectorInfo info = CzechIdMIcConvertUtil.convertConnectorClass(connectorAnnotation, (Class<? extends IcConnector>) defaultVirtualConnector);
    // Set connector key for VS
    system.setConnectorKey(new SysConnectorKeyDto(info.getConnectorKey()));
    system.setName(vsSystem.getName());
    // Create system
    system = this.systemService.save(system, IdmBasePermission.CREATE);
    // Find and update attributes for implementers
    IdmFormDefinitionDto connectorFormDef = this.systemService.getConnectorFormDefinition(system.getConnectorInstance());
    IdmFormAttributeDto implementersFormAttr = connectorFormDef.getMappedAttributeByCode(IMPLEMENTERS_PROPERTY);
    formService.saveValues(system, implementersFormAttr, new ArrayList<>(vsSystem.getImplementers()));
    IdmFormAttributeDto implementerRolesFormAttr = connectorFormDef.getMappedAttributeByCode(IMPLEMENTER_ROLES_PROPERTY);
    formService.saveValues(system, implementerRolesFormAttr, new ArrayList<>(vsSystem.getImplementerRoles()));
    IdmFormAttributeDto attributesFormAttr = connectorFormDef.getMappedAttributeByCode(ATTRIBUTES_PROPERTY);
    if (!vsSystem.getAttributes().isEmpty()) {
        formService.saveValues(system, attributesFormAttr, new ArrayList<>(vsSystem.getAttributes()));
    } else {
        List<Serializable> defaultAttributes = Lists.newArrayList((Serializable[]) BasicVirtualConfiguration.DEFAULT_ATTRIBUTES);
        defaultAttributes.add(RIGHTS_ATTRIBUTE);
        formService.saveValues(system, attributesFormAttr, defaultAttributes);
    }
    this.systemService.checkSystem(system);
    // Search attribute definition for rights and set him to multivalue
    String virtualSystemKey = MessageFormat.format("{0}:systemId={1}", system.getConnectorKey().getFullName(), system.getId().toString());
    String type = VsAccount.class.getName();
    IdmFormDefinitionDto definition = this.formService.getDefinition(type, virtualSystemKey);
    IdmFormAttributeDto rightsFormAttr = formAttributeService.findAttribute(type, definition.getCode(), RIGHTS_ATTRIBUTE);
    if (rightsFormAttr != null) {
        rightsFormAttr.setMultiple(true);
        formService.saveAttribute(rightsFormAttr);
    }
    // Generate schema
    List<SysSchemaObjectClassDto> schemas = this.systemService.generateSchema(system);
    SysSchemaObjectClassDto schemaAccount = schemas.stream().filter(schema -> IcObjectClassInfo.ACCOUNT.equals(schema.getObjectClassName())).findFirst().orElse(null);
    Assert.notNull(schemaAccount, "We cannot found schema for ACCOUNT!");
    // Create mapping by default attributes
    this.createDefaultMapping(system, schemaAccount, vsSystem);
    return this.systemService.get(system.getId());
}
Also used : Serializable(java.io.Serializable) BasicVirtualConnector(eu.bcvsolutions.idm.vs.connector.basic.BasicVirtualConnector) SysConnectorKeyDto(eu.bcvsolutions.idm.acc.dto.SysConnectorKeyDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) IcConnectorInfo(eu.bcvsolutions.idm.ic.api.IcConnectorInfo) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IcConnectorClass(eu.bcvsolutions.idm.ic.api.annotation.IcConnectorClass) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)

Example 4 with IcConnectorInfo

use of eu.bcvsolutions.idm.ic.api.IcConnectorInfo in project CzechIdMng by bcvsolutions.

the class ConnIdIcConfigurationService method getAvailableLocalConnectors.

/**
 * Return available local connectors for this IC implementation
 *
 * @return
 */
@Override
public Set<IcConnectorInfo> getAvailableLocalConnectors() {
    LOG.info("Get Available local connectors - ConnId");
    Set<IcConnectorInfo> localConnectorInfos = new HashSet<>();
    List<ConnectorInfoManager> managers = findAllLocalConnectorManagers();
    for (ConnectorInfoManager manager : managers) {
        List<ConnectorInfo> infos = manager.getConnectorInfos();
        if (infos == null) {
            continue;
        }
        for (ConnectorInfo info : infos) {
            ConnectorKey key = info.getConnectorKey();
            if (key == null) {
                continue;
            }
            IcConnectorKeyImpl keyDto = new IcConnectorKeyImpl(getFramework(), key.getBundleName(), key.getBundleVersion(), key.getConnectorName());
            IcConnectorInfoImpl infoDto = new IcConnectorInfoImpl(info.getConnectorDisplayName(), info.getConnectorCategory(), keyDto);
            localConnectorInfos.add(infoDto);
        }
    }
    return localConnectorInfos;
}
Also used : IcConnectorKeyImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorKeyImpl) IcConnectorInfoImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorInfoImpl) ConnectorKey(org.identityconnectors.framework.api.ConnectorKey) IcConnectorInfo(eu.bcvsolutions.idm.ic.api.IcConnectorInfo) ConnectorInfo(org.identityconnectors.framework.api.ConnectorInfo) IcConnectorInfo(eu.bcvsolutions.idm.ic.api.IcConnectorInfo) ConnectorInfoManager(org.identityconnectors.framework.api.ConnectorInfoManager) HashSet(java.util.HashSet)

Example 5 with IcConnectorInfo

use of eu.bcvsolutions.idm.ic.api.IcConnectorInfo in project CzechIdMng by bcvsolutions.

the class ConnIdIcConfigurationService method getAvailableRemoteConnectors.

@Override
public Set<IcConnectorInfo> getAvailableRemoteConnectors(IcConnectorServer server) {
    Assert.notNull(server);
    // 
    Set<IcConnectorInfo> result = new HashSet<>();
    // 
    List<ConnectorInfo> infos = getAllRemoteConnectors(server);
    for (ConnectorInfo info : infos) {
        ConnectorKey key = info.getConnectorKey();
        if (key == null) {
            continue;
        }
        // transform
        IcConnectorKeyImpl keyDto = new IcConnectorKeyImpl(getFramework(), key.getBundleName(), key.getBundleVersion(), key.getConnectorName());
        IcConnectorInfoImpl infoDto = new IcConnectorInfoImpl(info.getConnectorDisplayName(), info.getConnectorCategory(), keyDto);
        result.add(infoDto);
    }
    return result;
}
Also used : IcConnectorKeyImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorKeyImpl) IcConnectorInfoImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorInfoImpl) ConnectorKey(org.identityconnectors.framework.api.ConnectorKey) IcConnectorInfo(eu.bcvsolutions.idm.ic.api.IcConnectorInfo) ConnectorInfo(org.identityconnectors.framework.api.ConnectorInfo) IcConnectorInfo(eu.bcvsolutions.idm.ic.api.IcConnectorInfo) HashSet(java.util.HashSet)

Aggregations

IcConnectorInfo (eu.bcvsolutions.idm.ic.api.IcConnectorInfo)7 IcConnectorClass (eu.bcvsolutions.idm.ic.api.annotation.IcConnectorClass)3 IcException (eu.bcvsolutions.idm.ic.exception.IcException)3 IcConnectorInfoImpl (eu.bcvsolutions.idm.ic.impl.IcConnectorInfoImpl)3 IcConnectorKeyImpl (eu.bcvsolutions.idm.ic.impl.IcConnectorKeyImpl)3 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)2 IcConnector (eu.bcvsolutions.idm.ic.api.IcConnector)2 HashSet (java.util.HashSet)2 ConnectorInfo (org.identityconnectors.framework.api.ConnectorInfo)2 ConnectorKey (org.identityconnectors.framework.api.ConnectorKey)2 SysConnectorKeyDto (eu.bcvsolutions.idm.acc.dto.SysConnectorKeyDto)1 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)1 ConfigurationClass (eu.bcvsolutions.idm.core.api.domain.ConfigurationClass)1 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)1 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)1 IcConnectorConfiguration (eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration)1 IcConnectorInstance (eu.bcvsolutions.idm.ic.api.IcConnectorInstance)1 IcConnectorKey (eu.bcvsolutions.idm.ic.api.IcConnectorKey)1 IcConnectorConfigurationCzechIdMImpl (eu.bcvsolutions.idm.ic.czechidm.domain.IcConnectorConfigurationCzechIdMImpl)1 IcConnectorInstanceImpl (eu.bcvsolutions.idm.ic.impl.IcConnectorInstanceImpl)1