ConnectorInfoProviderService.java revision 88f2d7061bb42999901dcff81c37089b000d32e0
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsyncpackage org.forgerock.openidm.provisioner.openicf.impl;
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsyncimport org.forgerock.json.fluent.JsonValueException;
e90bc1b0a8fb83acc1c1dc65176f143163cbb1a4vboxsyncimport org.forgerock.openicf.framework.api.osgi.ConnectorManager;
c98fb3e16fcd571a790eab772c0c66173d225205vboxsyncimport org.forgerock.openidm.config.JSONEnhancedConfig;
c98fb3e16fcd571a790eab772c0c66173d225205vboxsyncimport org.forgerock.openidm.metadata.MetaDataProvider;
c98fb3e16fcd571a790eab772c0c66173d225205vboxsyncimport org.forgerock.openidm.metadata.WaitForMetaData;
c98fb3e16fcd571a790eab772c0c66173d225205vboxsyncimport org.forgerock.openidm.provisioner.openicf.ConnectorInfoProvider;
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsyncimport org.forgerock.openidm.provisioner.openicf.ConnectorReference;
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsyncimport org.forgerock.openidm.provisioner.openicf.commons.ConnectorUtil;
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsyncimport org.identityconnectors.framework.api.operations.SchemaApiOp;
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsyncimport org.identityconnectors.framework.api.operations.TestApiOp;
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsyncimport org.identityconnectors.framework.impl.api.APIConfigurationImpl;
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsyncimport org.identityconnectors.framework.impl.api.AbstractConnectorInfo;
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsyncimport org.identityconnectors.framework.impl.api.remote.RemoteConnectorInfoImpl;
4896726d903f56fe43eb13e2ba27ae1d63b8c40evboxsyncimport org.osgi.service.component.ComponentException;
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsyncimport java.lang.reflect.UndeclaredThrowableException;
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync * ConnectorInfoProviderService
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync * @author $author$
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync * @version $Revision$ $Date$
4e46eee5a96078ebec6cb36939b794a391f1ade0vboxsync@Component(name = ConnectorInfoProviderService.PID, policy = ConfigurationPolicy.OPTIONAL, description = "OpenICF Connector Info Service", immediate = true)
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync @Property(name = Constants.SERVICE_VENDOR, value = ServerConstants.SERVER_VENDOR_NAME),
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync @Property(name = Constants.SERVICE_DESCRIPTION, value = "OpenICF Connector Info Service")
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsyncpublic class ConnectorInfoProviderService implements ConnectorInfoProvider, MetaDataProvider {
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync private final static Logger TRACE = LoggerFactory.getLogger(ConnectorInfoProviderService.class);
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync //Public Constants
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync public static final String DEFAULT_CONNECTORS_LOCATION = "connectors";
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync public static final String PROPERTY_OPENICF_CONNECTOR_URL = "connectorsLocation";
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync public static final String PID = "org.forgerock.openidm.provisioner.openicf.connectorinfoprovider";
e06cbb510db6f327856cabc016398e4fda505809vboxsync private Map<String, RemoteFrameworkConnectionInfo> remoteFrameworkConnectionInfo = new HashMap<String, RemoteFrameworkConnectionInfo>();
10f224d85cd1135f0ca4ee1c1c1a7e15988bed58vboxsync * If this instance was instantiated for MetaDataProvider by Class#newInstance then this is false.
10f224d85cd1135f0ca4ee1c1c1a7e15988bed58vboxsync * If this instance was activated by OSGi SCR then this is true.
10f224d85cd1135f0ca4ee1c1c1a7e15988bed58vboxsync private boolean isOSGiServiceInstance = false;
607049337dcf359292c82c9372a2c19d9c4cdd2fvboxsync * ConnectorManager service.
607049337dcf359292c82c9372a2c19d9c4cdd2fvboxsync name = "ref_ConnectorManager_ConnectorInfoProvider",
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync private ConnectorManager osgiConnectorManager = null;
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync protected void activate(ComponentContext context) {
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync TRACE.trace("Activating Service with configuration {}", context.getProperties());
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync JsonValue configuration = getConfiguration(context);
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync // Create a single instance of ConnectorInfoManagerFactory
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync ConnectorInfoManagerFactory factory = ConnectorInfoManagerFactory.getInstance();
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync // String connectorLocation = DEFAULT_CONNECTORS_LOCATION;
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync String connectorLocation = configuration.get(PROPERTY_OPENICF_CONNECTOR_URL).defaultTo(DEFAULT_CONNECTORS_LOCATION).asString();
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync // Initialise Local ConnectorInfoManager
22cf3a5eb5a3cc2ea58e4fe974914e6a32514614vboxsync initialiseLocalManager(factory, connectorLocation);
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync TRACE.error("Invalid configuration {}", configuration.getValue(), e);
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync throw new ComponentException("Invalid configuration, service can not be started", e);
10f224d85cd1135f0ca4ee1c1c1a7e15988bed58vboxsync remoteConnectorHosts = configuration.get(ConnectorUtil.OPENICF_REMOTE_CONNECTOR_SERVERS).expect(List.class);
607049337dcf359292c82c9372a2c19d9c4cdd2fvboxsync initialiseRemoteManager(factory, remoteConnectorHosts);
607049337dcf359292c82c9372a2c19d9c4cdd2fvboxsync TRACE.error("Invalid configuration remoteConnectorHosts must be list or null. {}", remoteConnectorHosts, e);
10f224d85cd1135f0ca4ee1c1c1a7e15988bed58vboxsync throw new ComponentException("Invalid configuration, service can not be started", e);
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync protected void initialiseRemoteManager(ConnectorInfoManagerFactory factory, JsonValue remoteConnectorHosts) throws JsonValueException {
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync if (o instanceof Map) {
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync Map<String, Object> info = (Map<String, Object>) o;
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync RemoteFrameworkConnectionInfo rfi = ConnectorUtil.getRemoteFrameworkConnectionInfo(info);
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync } catch (Exception e) {
9e201d78ac6efdd08550263f2e146cdb76e9d49bvboxsync TRACE.error("Remote ConnectorServer: {} initialization failed.", rfi, e);
} catch (IllegalArgumentException e) {
TRACE.error("Configuration area [" + absolutePath + "] does not exist. Unable to load connectors.");
} catch (MalformedURLException e) {
} catch (UnsupportedEncodingException e) {
throw new UndeclaredThrowableException(e);
} catch (Throwable t) {
if (ConnectorReference.SINGLE_LOCAL_CONNECTOR_MANAGER.equals(connectorReference.getConnectorHost())) {
} else if (ConnectorReference.OSGI_SERVICE_CONNECTOR_MANAGER.equals(connectorReference.getConnectorHost())) {
RemoteFrameworkConnectionInfo rfci = remoteFrameworkConnectionInfo.get(connectorReference.getConnectorHost());
} catch (Exception e) {
return connectorInfo;
List<ConnectorInfo> result = new ArrayList<ConnectorInfo>(connectorInfoManager.getConnectorInfos());
} catch (Exception e) {
} catch (Exception e) {
public Map<String, Object> createSystemConfiguration(APIConfiguration configuration, boolean validate) {
} catch (Exception e) {
for (Map.Entry<String, RemoteFrameworkConnectionInfo> entry : remoteFrameworkConnectionInfo.entrySet()) {
return jsonConfiguration;
public List<JsonPointer> getPropertiesToEncrypt(String pidOrFactory, String instanceAlias, JsonValue config) throws WaitForMetaData {
JsonValue remoteConnectorHosts = config.get(ConnectorUtil.OPENICF_REMOTE_CONNECTOR_SERVERS).expect(List.class);
} catch (JsonValueException e) {
if (isOSGiServiceInstance) {
} catch (Exception e) {
JsonPointer configurationProperties = new JsonPointer(ConnectorUtil.OPENICF_CONFIGURATION_PROPERTIES);
return result;
} else if (("jar".equals(resourceURL.getProtocol())) || ("wsjar".equals(resourceURL.getProtocol()))) {
TRACE.info("Local connector support disabled. No support for bundle URLs with protocol {}", resourceURL.getProtocol());
} catch (URISyntaxException e) {
return connectorURLs;
return files;