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);
}
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;
}
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;
}
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);
}
}
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;
}
Aggregations