use of org.identityconnectors.framework.api.ConnectorInfoManager in project midpoint by Evolveum.
the class ConnectorFactoryConnIdImpl method isThisBundleCompatible.
/**
* Test if bundle internal configuration and dependencies are OK
* @param bundleUrl
* tested bundle URL
* @return true if OK
*/
private Boolean isThisBundleCompatible(URL bundleUrl) {
if (null == bundleUrl)
return false;
try {
ConnectorInfoManager localManager = ConnectorInfoManagerFactory.getInstance().getLocalManager(bundleUrl);
List<ConnectorInfo> connectorInfos = localManager.getConnectorInfos();
if (connectorInfos == null || connectorInfos.isEmpty()) {
LOGGER.error("Strange error happened. ConnId is not accepting bundle {}. But no error is indicated.", bundleUrl);
return false;
} else {
LOGGER.trace("Found {} compatible connectors in bundle {}", connectorInfos.size(), bundleUrl);
return true;
}
} catch (Exception ex) {
if (LOGGER.isDebugEnabled()) {
LOGGER.error("Error instantiating ICF bundle using URL '{}': {}", new Object[] { bundleUrl, ex.getMessage(), ex });
} else {
LOGGER.error("Error instantiating ICF bundle using URL '{}': {}", new Object[] { bundleUrl, ex.getMessage() });
}
return false;
}
}
use of org.identityconnectors.framework.api.ConnectorInfoManager in project syncope by apache.
the class ConnIdBundleManagerImpl method initLocal.
private void initLocal(final URI location) {
// 1. Find bundles inside local directory
File bundleDirectory = new File(location);
String[] bundleFiles = bundleDirectory.list();
if (bundleFiles == null) {
throw new NotFoundException("Local bundles directory " + location);
}
List<URL> bundleFileURLs = new ArrayList<>();
for (String file : bundleFiles) {
try {
bundleFileURLs.add(IOUtil.makeURL(bundleDirectory, file));
} catch (IOException ignore) {
// ignore exception and don't add bundle
LOG.debug("{}/{} is not a valid connector bundle", bundleDirectory.toString(), file, ignore);
}
}
if (bundleFileURLs.isEmpty()) {
LOG.warn("No connector bundles found in {}", location);
}
LOG.debug("Configuring local connector server:" + "\n\tFiles: {}", bundleFileURLs);
// 2. Get connector info manager
ConnectorInfoManager manager = ConnectorInfoManagerFactory.getInstance().getLocalManager(bundleFileURLs.toArray(new URL[bundleFileURLs.size()]));
if (manager == null) {
throw new NotFoundException("Local ConnectorInfoManager");
}
connInfoManagers.put(location, manager);
}
use of org.identityconnectors.framework.api.ConnectorInfoManager in project midpoint by Evolveum.
the class DirectoryScanningInfoManager method connectorFromURL.
Optional<ConnectorInfoManager> connectorFromURL(URI bundleUrl) {
try {
/*
* We can not reuse one instance of ConnectorInfoManager, since it is immutable.
* We need to create it per instance, since connector info construction is hidden
* behind private methods.
*
* Fortunately ConnectorInfoManager does not hold any additional functionality
* besides initialization of basic connector info and lookup in locally loaded connector
* infos, thus we can have separate instance per bundle uri.
*
*
*/
ConnectorInfoManager localManager = factory.getLocalManager(bundleUrl.toURL());
List<ConnectorInfo> connectorInfos = localManager.getConnectorInfos();
if (connectorInfos == null || connectorInfos.isEmpty()) {
LOGGER.error("Strange error happened. ConnId is not accepting bundle {}. But no error is indicated.", bundleUrl);
return Optional.empty();
} else {
LOGGER.trace("Found {} compatible connectors in bundle {}", connectorInfos.size(), bundleUrl);
return Optional.of(localManager);
}
} catch (Exception ex) {
if (LOGGER.isDebugEnabled()) {
LOGGER.error("Error instantiating ICF bundle using URL '{}': {}", bundleUrl, ex.getMessage(), ex);
} else {
LOGGER.error("Error instantiating ICF bundle using URL '{}': {}", bundleUrl, ex.getMessage());
}
return Optional.empty();
}
}
use of org.identityconnectors.framework.api.ConnectorInfoManager in project CzechIdMng by bcvsolutions.
the class ConnIdIcConfigurationService method findRemoteConnectorManager.
private ConnectorInfoManager findRemoteConnectorManager(IcConnectorServer server) {
// get all saved remote connector servers
ConnectorInfoManager manager = null;
try {
GuardedString pass = server.getPassword();
if (pass == null) {
throw new InvalidCredentialException();
}
RemoteFrameworkConnectionInfo info = new RemoteFrameworkConnectionInfo(server.getHost(), server.getPort(), new org.identityconnectors.common.security.GuardedString(pass.asString().toCharArray()), server.isUseSsl(), null, server.getTimeout());
// flush remote cache
ConnectorInfoManagerFactory instance = ConnectorInfoManagerFactory.getInstance();
instance.clearRemoteCache();
manager = instance.getRemoteManager(info);
} catch (InvalidCredentialException e) {
throw new IcInvalidCredentialException(server.getHost(), server.getPort(), e);
} catch (ConnectorIOException e) {
throw new IcServerNotFoundException(server.getHost(), server.getPort(), e);
} catch (ConnectorException e) {
throw new IcCantConnectException(server.getHost(), server.getPort(), e);
} catch (Exception e) {
throw new IcRemoteServerException(server.getHost(), server.getPort(), e);
}
return manager;
}
use of org.identityconnectors.framework.api.ConnectorInfoManager in project CzechIdMng by bcvsolutions.
the class ConnIdIcConfigurationService method getRemoteConnIdConnectorInfo.
private ConnectorInfo getRemoteConnIdConnectorInfo(IcConnectorInstance connectorInstance) {
Assert.notNull(connectorInstance.getConnectorKey(), "Connector key is required.");
Assert.notNull(connectorInstance.getConnectorServer(), "Connector server is required.");
ConnectorInfoManager remoteInfoManager = findRemoteConnectorManager(connectorInstance.getConnectorServer());
for (ConnectorInfo info : remoteInfoManager.getConnectorInfos()) {
ConnectorKey connectorKey = info.getConnectorKey();
if (connectorKey == null) {
continue;
} else if (connectorKey.getConnectorName().equals(connectorInstance.getConnectorKey().getConnectorName())) {
return info;
}
}
return null;
}
Aggregations