Search in sources :

Example 1 with IcConnector

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

the class CzechIdMIcConfigurationService method validate.

public void validate(IcConnectorInstance connectorInstance, IcConnectorConfiguration connectorConfiguration) {
    Assert.notNull(connectorInstance, "Connector instance cannot be null!");
    LOG.debug("Validate connector - CzechIdM ({})", connectorInstance.getConnectorServer().getFullServerName());
    Assert.notNull(connectorConfiguration, "Connector configuration cannot be null!");
    IcConnector connector = this.createConnectorInstance(connectorInstance);
    Assert.notNull(connector, "Connector instance must be created!");
    connector.init(connectorConfiguration);
}
Also used : IcConnector(eu.bcvsolutions.idm.ic.api.IcConnector)

Example 2 with IcConnector

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

the class CzechIdMIcConfigurationService method createConnectorInstance.

/**
 * Create instance of connector
 *
 * @param connectorInstance
 * @return
 */
private IcConnector createConnectorInstance(IcConnectorInstance connectorInstance) {
    IcConnector connector = null;
    Class<? extends IcConnector> connectorClass = this.getConnectorClass(connectorInstance);
    try {
        connector = connectorClass.newInstance();
        // Manually autowire on this connector instance
        this.applicationContext.getAutowireCapableBeanFactory().autowireBean(connector);
    } catch (InstantiationException | IllegalAccessException e) {
        throw new CoreException(e);
    }
    return connector;
}
Also used : CoreException(eu.bcvsolutions.idm.core.api.exception.CoreException) IcConnector(eu.bcvsolutions.idm.ic.api.IcConnector)

Example 3 with IcConnector

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

the class CzechIdMIcConnectorService method updateObject.

@Override
public IcUidAttribute updateObject(IcConnectorInstance connectorInstance, IcConnectorConfiguration connectorConfiguration, IcObjectClass objectClass, IcUidAttribute uid, List<IcAttribute> replaceAttributes) {
    Assert.notNull(connectorInstance);
    Assert.notNull(connectorInstance.getConnectorKey());
    Assert.notNull(connectorConfiguration);
    Assert.notNull(replaceAttributes);
    Assert.notNull(uid);
    String key = connectorInstance.getConnectorKey().toString();
    LOG.debug("Update object - CzechIdM (Uid= {} {} {})", uid, key, replaceAttributes.toString());
    if (objectClass == null) {
        objectClass = new IcObjectClassImpl(IcObjectClassInfo.ACCOUNT);
    }
    IcConnector connector = this.getConnectorInstance(connectorInstance, connectorConfiguration);
    if (!(connector instanceof IcCanUpdate)) {
        throw new IcException(MessageFormat.format("Connector [{0}] not supports update operation!", key));
    }
    IcUidAttribute updatedUid = ((IcCanUpdate) connector).update(uid, objectClass, replaceAttributes);
    LOG.debug("Updated object - CzechIdM ({} {}) Uid= {})", connectorInstance.getConnectorKey().toString(), replaceAttributes.toString(), updatedUid);
    return updatedUid;
}
Also used : IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) IcCanUpdate(eu.bcvsolutions.idm.ic.api.operation.IcCanUpdate) IcConnector(eu.bcvsolutions.idm.ic.api.IcConnector) IcException(eu.bcvsolutions.idm.ic.exception.IcException) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute)

Example 4 with IcConnector

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

the class CzechIdMIcConnectorService method getConnectorInstance.

@Override
public IcConnector getConnectorInstance(IcConnectorInstance connectorInstance, IcConnectorConfiguration connectorConfiguration) {
    Assert.notNull(connectorInstance.getConnectorKey());
    Assert.notNull(connectorConfiguration);
    // String key = connectorInstance.getConnectorKey().getFullName();
    // Cache is not thread safety
    // if(this.connectorInstances.containsKey(key)){
    // IcConnector connector = connectorInstances.get(key);
    // connector.init(connectorConfiguration);
    // return connector;
    // }
    Class<? extends IcConnector> connectorClass = this.configurationService.getConnectorClass(connectorInstance);
    try {
        IcConnector connector = connectorClass.newInstance();
        // Manually autowire on this connector instance
        this.applicationContext.getAutowireCapableBeanFactory().autowireBean(connector);
        connector.init(connectorConfiguration);
        // this.connectorInstances.put(key, connector);
        return connector;
    } catch (InstantiationException | IllegalAccessException e) {
        throw new IcException(e);
    }
}
Also used : IcConnector(eu.bcvsolutions.idm.ic.api.IcConnector) IcException(eu.bcvsolutions.idm.ic.exception.IcException)

Example 5 with IcConnector

use of eu.bcvsolutions.idm.ic.api.IcConnector 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)

Aggregations

IcConnector (eu.bcvsolutions.idm.ic.api.IcConnector)11 IcException (eu.bcvsolutions.idm.ic.exception.IcException)9 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)5 IcObjectClassImpl (eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl)4 IcConnectorInfo (eu.bcvsolutions.idm.ic.api.IcConnectorInfo)2 IcUidAttribute (eu.bcvsolutions.idm.ic.api.IcUidAttribute)2 ConfigurationClass (eu.bcvsolutions.idm.core.api.domain.ConfigurationClass)1 CoreException (eu.bcvsolutions.idm.core.api.exception.CoreException)1 IcConnectorConfiguration (eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration)1 IcConnectorInstance (eu.bcvsolutions.idm.ic.api.IcConnectorInstance)1 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)1 IcSchema (eu.bcvsolutions.idm.ic.api.IcSchema)1 IcConnectorClass (eu.bcvsolutions.idm.ic.api.annotation.IcConnectorClass)1 IcCanCreate (eu.bcvsolutions.idm.ic.api.operation.IcCanCreate)1 IcCanDelete (eu.bcvsolutions.idm.ic.api.operation.IcCanDelete)1 IcCanGenSchema (eu.bcvsolutions.idm.ic.api.operation.IcCanGenSchema)1 IcCanRead (eu.bcvsolutions.idm.ic.api.operation.IcCanRead)1 IcCanSearch (eu.bcvsolutions.idm.ic.api.operation.IcCanSearch)1 IcCanUpdate (eu.bcvsolutions.idm.ic.api.operation.IcCanUpdate)1 IcConnectorInstanceImpl (eu.bcvsolutions.idm.ic.impl.IcConnectorInstanceImpl)1