private ConnectorInfoManager getConnectorInfoManager() { ConnectorInfoManagerFactoryImpl factory = (ConnectorInfoManagerFactoryImpl) ConnectorInfoManagerFactory.getInstance(); return factory.getLocalManager(connectorServer.getBundleURLs(), connectorServer .getBundleParentClassLoader()); }
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); }
ConnectorInfoManager manager = ConnectorInfoManagerFactory.getInstance().getRemoteManager(info); if (manager == null) { throw new NotFoundException("Remote ConnectorInfoManager");
/** * Returns ICF connector info manager that manages local connectors. The * manager will be created if it does not exist yet. * * @return ICF connector info manager that manages local connectors */ private ConnectorInfoManager getLocalConnectorInfoManager() { if (null == localConnectorInfoManager) { URL[] urls = bundleURIs.stream().map(MiscUtil::toUrlUnchecked).toArray(URL[]::new); localConnectorInfoManager = connectorInfoManagerFactory.getLocalManager(urls); } return localConnectorInfoManager; }
manager = fact.getRemoteManager(new RemoteFrameworkConnectionInfo(host, port, new GuardedString(key.toCharArray())));
connectorInfoManagerFactory.clearRemoteCache(); Set<ConnectorType> connectors = listRemoteConnectors(host); result.recordSuccess();
/** * Returns local manager or null. * @param dataProvider * @param fact * @return null in case configuration is NOT provided * @throws RuntimeException if creation fails although properties were provided */ private static ConnectorInfoManager getLocalManager(final DataProvider dataProvider, final ConnectorInfoManagerFactory fact) { ConnectorInfoManager manager = null; // try to load bundleJar property (which should be set by ant) File bundleJar = new File(((String) dataProvider.getTestSuiteAttribute("bundleJar")).trim()); Assert.assertTrue("BundleJar does not exist: " + bundleJar.getAbsolutePath(), bundleJar .isFile()); try { manager = fact.getLocalManager(bundleJar.toURI().toURL()); } catch (MalformedURLException ex) { throw ContractException.wrap(ex); } return manager; }
manager = fact.getRemoteManager(new RemoteFrameworkConnectionInfo(host, port, new GuardedString(key.toCharArray()))); } catch (Throwable t) {
private ConnectorInfoManager getConnectorInfoManager() { ConnectorInfoManagerFactoryImpl factory = (ConnectorInfoManagerFactoryImpl) ConnectorInfoManagerFactory.getInstance(); return factory.getLocalManager(connectorServer.getBundleURLs(), connectorServer .getBundleParentClassLoader()); }
/** * 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; } }
/** * Returns local manager or null. * * @param dataProvider * @param fact * @return null in case configuration is NOT provided * @throws RuntimeException if creation fails although properties were provided */ private static ConnectorInfoManager getLocalManager(final DataProvider dataProvider, final ConnectorInfoManagerFactory fact) { ConnectorInfoManager manager = null; // try to load bundleJar property (which should be set by ant) File bundleJar = new File(((String) dataProvider.getTestSuiteAttribute("bundleJar")).trim()); assertTrue("BundleJar does not exist: " + bundleJar.getAbsolutePath(), bundleJar.isFile()); try { manager = fact.getLocalManager(bundleJar.toURI().toURL()); } catch (MalformedURLException ex) { throw ContractException.wrap(ex); } return manager; }
manager = fact.getRemoteManager( new RemoteFrameworkConnectionInfo(host, port, new GuardedString(key.toCharArray()))); } catch (Throwable t) {
private ConnectorInfoManager getConnectorInfoManager() { ConnectorInfoManagerFactoryImpl factory = (ConnectorInfoManagerFactoryImpl) ConnectorInfoManagerFactory.getInstance(); return factory.getLocalManager(_server.getBundleURLs(), _server.getBundleParentClassLoader()); }
/** * Returns local manager or null. * * @param dataProvider * @param fact * @return null in case configuration is NOT provided * @throws RuntimeException if creation fails although properties were provided */ private static ConnectorInfoManager getLocalManager(final DataProvider dataProvider, final ConnectorInfoManagerFactory fact) { ConnectorInfoManager manager = null; // try to load bundleJar property (which should be set by ant) File bundleJar = new File(((String) dataProvider.getTestSuiteAttribute("bundleJar")).trim()); assertTrue(bundleJar.isFile(), "BundleJar does not exist: " + bundleJar.getAbsolutePath()); try { manager = fact.getLocalManager(bundleJar.toURI().toURL()); } catch (MalformedURLException ex) { throw ContractException.wrap(ex); } return manager; }
/** * Returns ICF connector info manager that manages local connectors. The * manager will be created if it does not exist yet. * * @return ICF connector info manager that manages local connectors */ private ConnectorInfoManager getRemoteConnectorInfoManager(ConnectorHostType hostType) { String hostname = hostType.getHostname(); int port = Integer.parseInt(hostType.getPort()); GuardedString key; try { key = new GuardedString(protector.decryptString(hostType.getSharedSecret()).toCharArray()); } catch (EncryptionException e) { throw new SystemException("Shared secret decryption error: "+e.getMessage(),e); } Integer timeout = hostType.getTimeout(); if (timeout == null) { timeout = 0; } boolean useSSL = false; if (hostType.isProtectConnection() != null) { useSSL = hostType.isProtectConnection(); } List<TrustManager> trustManagers = protector.getTrustManagers(); LOGGER.trace("Creating RemoteFrameworkConnectionInfo: hostname={}, port={}, key={}, useSSL={}, trustManagers={}, timeout={}", new Object[] {hostname, port, key, useSSL, trustManagers, timeout}); RemoteFrameworkConnectionInfo remoteFramewrorkInfo = new RemoteFrameworkConnectionInfo(hostname, port, key, useSSL, trustManagers, timeout); return connectorInfoManagerFactory.getRemoteManager(remoteFramewrorkInfo); }
/** * Initialize the ICF implementation. Look for all connector bundles, get * basic information about them and keep that in memory. */ @PostConstruct public void initialize() { // OLD // bundleURIs = listBundleJars(); bundleURIs = new HashSet<>(); Configuration config = midpointConfiguration.getConfiguration(MidpointConfiguration.ICF_CONFIGURATION); // Is classpath scan enabled if (config.getBoolean("scanClasspath")) { // Scan class path bundleURIs.addAll(scanClassPathForBundles()); } // Scan all provided directories @SuppressWarnings("unchecked") List<String> dirs = config.getList("scanDirectory"); for (String dir : dirs) { bundleURIs.addAll(scanDirectory(dir)); } for (URI u : bundleURIs) { LOGGER.debug("ICF bundle URI : {}", u); } connectorInfoManagerFactory = ConnectorInfoManagerFactory.getInstance(); }
/** * Tries to create remote or local manager. Remote manager is created in case all connectorserver properties are * set. If connectorserver properties are missing or remote manager creation fails then tries to create local * manager. */ public static ConnectorInfoManager getInfoManager(final DataProvider dataProvider) { ConnectorInfoManagerFactory fact = ConnectorInfoManagerFactory.getInstance(); ConnectorInfoManager manager = null; String useConnectorServer = System.getProperty("useConnectorServer"); if ("true".equals(useConnectorServer)) { LOG.info("TESTING CONNECTOR ON CONNECTOR SERVER."); manager = getRemoteManager(dataProvider, fact); } else { LOG.info("TESTING LOCAL CONNECTOR."); manager = getLocalManager(dataProvider, fact); } assertNotNull("Manager wasn't created - check *MANDATORY* properties.", manager); return manager; }
/** * Tries to create remote or local manager. * Remote manager is created in case all connectorserver properties are set. If connectorserver properties are * missing * or remote manager creation fails then tries to create local manager. */ public static ConnectorInfoManager getInfoManager(final DataProvider dataProvider) { ConnectorInfoManagerFactory fact = ConnectorInfoManagerFactory.getInstance(); ConnectorInfoManager manager = null; String useConnectorServer = System.getProperty("useConnectorServer"); if ("true".equals(useConnectorServer)) { LOG.info("TESTING CONNECTOR ON CONNECTOR SERVER."); manager = getRemoteManager(dataProvider, fact); } else { LOG.info("TESTING LOCAL CONNECTOR."); manager = getLocalManager(dataProvider, fact); } assertNotNull(manager, "Manager wasn't created - check *MANDATORY* properties."); return manager; }
/** * Tries to create remote or local manager. * Remote manager is created in case all connectorserver properties are set. If connectorserver properties are missing * or remote manager creation fails then tries to create local manager. */ public static ConnectorInfoManager getInfoManager(final DataProvider dataProvider) { ConnectorInfoManagerFactory fact = ConnectorInfoManagerFactory.getInstance(); ConnectorInfoManager manager = null; String useConnectorServer = System.getProperty("useConnectorServer"); if ("true".equals(useConnectorServer)) { LOG.info("TESTING CONNECTOR ON CONNECTOR SERVER."); manager = getRemoteManager(dataProvider, fact); } else { LOG.info("TESTING LOCAL CONNECTOR."); manager = getLocalManager(dataProvider, fact); } assertNotNull("Manager wasn't created - check *MANDATORY* properties.", manager); return manager; }
@Override public void start() { if (isStarted()) { throw new IllegalStateException("Server is already running."); } if (getPort() == 0) { throw new IllegalStateException("Port must be set prior to starting server."); } if (getKeyHash() == null) { throw new IllegalStateException("Key hash must be set prior to starting server."); } // make sure we are configured properly final ConnectorInfoManagerFactoryImpl factory = (ConnectorInfoManagerFactoryImpl) ConnectorInfoManagerFactory.getInstance(); factory.getLocalManager(getBundleURLs(), getBundleParentClassLoader()); final ServerSocket socket = createServerSocket(); final ConnectionListener listener = new ConnectionListener(this, socket); listener.start(); stopLatch = new CountDownLatch(1); startDate = System.currentTimeMillis(); this.listener = listener; }