Search in sources :

Example 1 with ConnectorInfoManager

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;
    }
}
Also used : ConnectorInfo(org.identityconnectors.framework.api.ConnectorInfo) ConnectorInfoManager(org.identityconnectors.framework.api.ConnectorInfoManager) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ConnIdUtil.processIcfException(com.evolveum.midpoint.provisioning.ucf.impl.connid.ConnIdUtil.processIcfException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) SystemException(com.evolveum.midpoint.util.exception.SystemException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) EncryptionException(com.evolveum.midpoint.prism.crypto.EncryptionException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 2 with ConnectorInfoManager

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);
}
Also used : ConnectorInfoManager(org.identityconnectors.framework.api.ConnectorInfoManager) ArrayList(java.util.ArrayList) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) GuardedString(org.identityconnectors.common.security.GuardedString) IOException(java.io.IOException) File(java.io.File) URL(java.net.URL)

Example 3 with ConnectorInfoManager

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();
    }
}
Also used : ConnectorInfo(org.identityconnectors.framework.api.ConnectorInfo) ConnectorInfoManager(org.identityconnectors.framework.api.ConnectorInfoManager)

Example 4 with ConnectorInfoManager

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;
}
Also used : ConnectorIOException(org.identityconnectors.framework.common.exceptions.ConnectorIOException) IcServerNotFoundException(eu.bcvsolutions.idm.ic.exception.IcServerNotFoundException) IcInvalidCredentialException(eu.bcvsolutions.idm.ic.exception.IcInvalidCredentialException) IcInvalidCredentialException(eu.bcvsolutions.idm.ic.exception.IcInvalidCredentialException) InvalidCredentialException(org.identityconnectors.framework.common.exceptions.InvalidCredentialException) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IcRemoteServerException(eu.bcvsolutions.idm.ic.exception.IcRemoteServerException) ConnectorException(org.identityconnectors.framework.common.exceptions.ConnectorException) IcInvalidCredentialException(eu.bcvsolutions.idm.ic.exception.IcInvalidCredentialException) InvalidCredentialException(org.identityconnectors.framework.common.exceptions.InvalidCredentialException) IcCantConnectException(eu.bcvsolutions.idm.ic.exception.IcCantConnectException) IcServerNotFoundException(eu.bcvsolutions.idm.ic.exception.IcServerNotFoundException) CoreException(eu.bcvsolutions.idm.core.api.exception.CoreException) ConnectorIOException(org.identityconnectors.framework.common.exceptions.ConnectorIOException) ConnectorInfoManagerFactory(org.identityconnectors.framework.api.ConnectorInfoManagerFactory) ConnectorInfoManager(org.identityconnectors.framework.api.ConnectorInfoManager) IcCantConnectException(eu.bcvsolutions.idm.ic.exception.IcCantConnectException) ConnectorException(org.identityconnectors.framework.common.exceptions.ConnectorException) IcRemoteServerException(eu.bcvsolutions.idm.ic.exception.IcRemoteServerException) RemoteFrameworkConnectionInfo(org.identityconnectors.framework.api.RemoteFrameworkConnectionInfo)

Example 5 with ConnectorInfoManager

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;
}
Also used : ConnectorKey(org.identityconnectors.framework.api.ConnectorKey) ConnectorInfo(org.identityconnectors.framework.api.ConnectorInfo) IcConnectorInfo(eu.bcvsolutions.idm.ic.api.IcConnectorInfo) ConnectorInfoManager(org.identityconnectors.framework.api.ConnectorInfoManager)

Aggregations

ConnectorInfoManager (org.identityconnectors.framework.api.ConnectorInfoManager)9 ConnectorInfo (org.identityconnectors.framework.api.ConnectorInfo)4 ArrayList (java.util.ArrayList)3 IcConnectorInfo (eu.bcvsolutions.idm.ic.api.IcConnectorInfo)2 IOException (java.io.IOException)2 URL (java.net.URL)2 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)2 GuardedString (org.identityconnectors.common.security.GuardedString)2 ConnectorInfoManagerFactory (org.identityconnectors.framework.api.ConnectorInfoManagerFactory)2 ConnectorKey (org.identityconnectors.framework.api.ConnectorKey)2 RemoteFrameworkConnectionInfo (org.identityconnectors.framework.api.RemoteFrameworkConnectionInfo)2 EncryptionException (com.evolveum.midpoint.prism.crypto.EncryptionException)1 ConnIdUtil.processIcfException (com.evolveum.midpoint.provisioning.ucf.impl.connid.ConnIdUtil.processIcfException)1 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 SystemException (com.evolveum.midpoint.util.exception.SystemException)1 CoreException (eu.bcvsolutions.idm.core.api.exception.CoreException)1 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)1 IcCantConnectException (eu.bcvsolutions.idm.ic.exception.IcCantConnectException)1