Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2018-03-13 14:03:21 -0400
committerslewis2018-03-13 14:03:21 -0400
commiteb1a4ff73d8860fb04ff5051ffb178cb6bc5d926 (patch)
treee588c702a95d6f8bc4031b28666d0c1173d9eb8a /framework/bundles
parent2e67e4c37bea37d8f1fdb27455a3ceeac097d3ba (diff)
downloadorg.eclipse.ecf-eb1a4ff73d8860fb04ff5051ffb178cb6bc5d926.tar.gz
org.eclipse.ecf-eb1a4ff73d8860fb04ff5051ffb178cb6bc5d926.tar.xz
org.eclipse.ecf-eb1a4ff73d8860fb04ff5051ffb178cb6bc5d926.zip
Dependency fixes for bug
https://bugs.eclipse.org/bugs/show_bug.cgi?id=532205 Adds support for osgi.private in ecf generic, ecf ssl, and rosgi providers, as well as a framework in ecf core and rsa impl for any other distribution providers. Change-Id: I5cacab08ba5b6fe63b8550fdb70eb8d6d1357977
Diffstat (limited to 'framework/bundles')
-rw-r--r--framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/GenericContainerInstantiator.java21
-rw-r--r--framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SSLGenericContainerInstantiator.java21
-rw-r--r--framework/bundles/org.eclipse.ecf/META-INF/MANIFEST.MF4
-rw-r--r--framework/bundles/org.eclipse.ecf/pom.xml2
-rw-r--r--framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/provider/ContainerInstantiatorUtils.java134
-rw-r--r--framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/provider/ContainerIntentException.java43
6 files changed, 211 insertions, 14 deletions
diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/GenericContainerInstantiator.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/GenericContainerInstantiator.java
index 1f1e7a8f5..a8a5fb3b2 100644
--- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/GenericContainerInstantiator.java
+++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/GenericContainerInstantiator.java
@@ -16,8 +16,7 @@ import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.ecf.core.*;
import org.eclipse.ecf.core.identity.*;
-import org.eclipse.ecf.core.provider.IContainerInstantiator;
-import org.eclipse.ecf.core.provider.IRemoteServiceContainerInstantiator;
+import org.eclipse.ecf.core.provider.*;
import org.eclipse.ecf.core.util.Trace;
import org.eclipse.ecf.internal.provider.ECFProviderDebugOptions;
import org.eclipse.ecf.internal.provider.ProviderPlugin;
@@ -27,7 +26,7 @@ public class GenericContainerInstantiator implements IContainerInstantiator, IRe
/**
* @since 2.0
*/
- protected static final String[] genericProviderIntents = {"osgi.basic", "osgi.async", "passByValue", "exactlyOnce", "ordered"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ protected static final String[] genericProviderIntents = {"osgi.basic", "osgi.async", "osgi.private", "passByValue", "exactlyOnce", "ordered"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
public static final String TCPCLIENT_NAME = "ecf.generic.client"; //$NON-NLS-1$
@@ -162,16 +161,18 @@ public class GenericContainerInstantiator implements IContainerInstantiator, IRe
* @param args arguments
* @return GenericContainerArgs the server args created
* @throws IDCreateException if the server args cannot be retrieved from given args
+ * @throws ContainerIntentException
* @since 3.0
*/
- protected GenericContainerArgs getServerArgs(Object[] args) throws IDCreateException {
+ protected GenericContainerArgs getServerArgs(Object[] args) throws IDCreateException, ContainerIntentException {
ID newID = null;
Integer ka = null;
InetAddress bindAddress = null;
-
+ boolean privateIntent = false;
if (args != null && args.length > 0) {
if (args[0] instanceof Map) {
- Map map = (Map) args[0];
+ @SuppressWarnings("unchecked")
+ Map<String, Object> map = (Map<String, Object>) args[0];
Object idVal = map.get(ID_PROP);
if (idVal != null) {
newID = getIDFromArg(idVal);
@@ -209,6 +210,9 @@ public class GenericContainerInstantiator implements IContainerInstantiator, IRe
if (o == null)
o = map.get(KEEPALIVE_PROP.toLowerCase());
ka = getIntegerFromArg(o);
+ // Get private intent if present
+ privateIntent = ContainerInstantiatorUtils.containsPrivateIntent(map);
+
} else if (args.length > 1) {
if (args[0] instanceof String || args[0] instanceof ID)
newID = getIDFromArg(args[0]);
@@ -223,6 +227,11 @@ public class GenericContainerInstantiator implements IContainerInstantiator, IRe
}
if (ka == null)
ka = new Integer(TCPServerSOContainer.DEFAULT_KEEPALIVE);
+
+ // Check private intent
+ if (privateIntent)
+ ContainerInstantiatorUtils.checkPrivate(newID);
+
return new GenericContainerArgs(newID, ka, bindAddress);
}
diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SSLGenericContainerInstantiator.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SSLGenericContainerInstantiator.java
index bf524d6d6..99fae3e9c 100644
--- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SSLGenericContainerInstantiator.java
+++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SSLGenericContainerInstantiator.java
@@ -18,8 +18,7 @@ import javax.net.ssl.SSLServerSocketFactory;
import org.eclipse.core.runtime.*;
import org.eclipse.ecf.core.*;
import org.eclipse.ecf.core.identity.*;
-import org.eclipse.ecf.core.provider.IContainerInstantiator;
-import org.eclipse.ecf.core.provider.IRemoteServiceContainerInstantiator;
+import org.eclipse.ecf.core.provider.*;
import org.eclipse.ecf.core.util.Trace;
import org.eclipse.ecf.internal.provider.ECFProviderDebugOptions;
import org.eclipse.ecf.internal.provider.ProviderPlugin;
@@ -29,7 +28,7 @@ import org.eclipse.ecf.internal.provider.ProviderPlugin;
*/
public class SSLGenericContainerInstantiator implements IContainerInstantiator, IRemoteServiceContainerInstantiator {
- protected static final String[] genericProviderIntents = {"passByValue", "exactlyOnce", "ordered",}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ protected static final String[] genericProviderIntents = {"osgi.basic", "osgi.async", "osgi.private", "passByValue", "exactlyOnce", "ordered"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
public static final String SSLCLIENT_NAME = "ecf.generic.ssl.client"; //$NON-NLS-1$
@@ -197,17 +196,20 @@ public class SSLGenericContainerInstantiator implements IContainerInstantiator,
* @param args arguments
* @return GenericContainerArgs the client args created
* @throws IDCreateException if the client args cannot be retrieved from given args
+ * @throws ContainerIntentException
* @since 3.0
*/
- protected GenericContainerArgs getServerArgs(Object[] args) throws IDCreateException {
+ protected GenericContainerArgs getServerArgs(Object[] args) throws IDCreateException, ContainerIntentException {
ID newID = null;
Integer ka = null;
InetAddress bindAddress = null;
boolean wantClientAuth = false;
boolean needClientAuth = false;
+ boolean privateIntent = false;
if (args != null && args.length > 0) {
if (args[0] instanceof Map) {
- Map map = (Map) args[0];
+ @SuppressWarnings("unchecked")
+ Map<String, Object> map = (Map<String, Object>) args[0];
Object idVal = map.get(ID_PROP);
if (idVal != null) {
newID = getIDFromArg(idVal);
@@ -251,6 +253,10 @@ public class SSLGenericContainerInstantiator implements IContainerInstantiator,
Object wantClientAuthVal = map.get(WANTCLIENTAUTH_PROP);
if (wantClientAuthVal instanceof Boolean)
wantClientAuth = ((Boolean) wantClientAuthVal).booleanValue();
+
+ // Get private intent if present
+ privateIntent = ContainerInstantiatorUtils.containsPrivateIntent(map);
+
} else if (args.length > 1) {
if (args[0] instanceof String || args[0] instanceof ID)
newID = getIDFromArg(args[0]);
@@ -272,6 +278,11 @@ public class SSLGenericContainerInstantiator implements IContainerInstantiator,
}
if (ka == null)
ka = new Integer(SSLServerSOContainer.DEFAULT_KEEPALIVE);
+
+ // Check for private intent
+ if (privateIntent)
+ ContainerInstantiatorUtils.checkPrivate(newID);
+
return new GenericContainerArgs(newID, ka, bindAddress, wantClientAuth, needClientAuth);
}
diff --git a/framework/bundles/org.eclipse.ecf/META-INF/MANIFEST.MF b/framework/bundles/org.eclipse.ecf/META-INF/MANIFEST.MF
index 99715200f..5412a9f3b 100644
--- a/framework/bundles/org.eclipse.ecf/META-INF/MANIFEST.MF
+++ b/framework/bundles/org.eclipse.ecf/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-Name: %plugin.name
Bundle-SymbolicName: org.eclipse.ecf;singleton:=true
Automatic-Module-Name: org.eclipse.ecf
-Bundle-Version: 3.8.0.qualifier
+Bundle-Version: 3.9.0.qualifier
Bundle-Activator: org.eclipse.ecf.internal.core.ECFPlugin
Bundle-Vendor: %plugin.provider
Bundle-Localization: plugin
@@ -12,7 +12,7 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.eclipse.ecf.core;version="3.0.0",
org.eclipse.ecf.core.events;version="3.1.0",
org.eclipse.ecf.core.jobs;version="1.1.0",
- org.eclipse.ecf.core.provider;version="3.1.0",
+ org.eclipse.ecf.core.provider;version="3.2.0",
org.eclipse.ecf.core.security;version="3.1.0",
org.eclipse.ecf.core.start;version="3.1.0",
org.eclipse.ecf.core.status;version="1.1.0",
diff --git a/framework/bundles/org.eclipse.ecf/pom.xml b/framework/bundles/org.eclipse.ecf/pom.xml
index 3cbd4742d..a10f42c7f 100644
--- a/framework/bundles/org.eclipse.ecf/pom.xml
+++ b/framework/bundles/org.eclipse.ecf/pom.xml
@@ -10,6 +10,6 @@
</parent>
<groupId>org.eclipse.ecf</groupId>
<artifactId>org.eclipse.ecf</artifactId>
- <version>3.8.0-SNAPSHOT</version>
+ <version>3.9.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/provider/ContainerInstantiatorUtils.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/provider/ContainerInstantiatorUtils.java
new file mode 100644
index 000000000..72e469d03
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/provider/ContainerInstantiatorUtils.java
@@ -0,0 +1,134 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.core.provider;
+
+import java.net.*;
+import java.util.*;
+import org.eclipse.ecf.core.identity.ID;
+import org.osgi.framework.Constants;
+
+/**
+ * @since 3.9
+ */
+public class ContainerInstantiatorUtils {
+
+ public static final String PRIVATE_INTENT = "osgi.private"; //$NON-NLS-1$
+
+ /**
+ * @since 3.9
+ */
+ public static String[] getContainerIntents(Map<String, ?> properties) {
+ return getStringArrayProperty(properties, Constants.SERVICE_INTENTS);
+ }
+
+ /**
+ * @since 3.9
+ */
+ public static boolean containsIntent(String[] intents, String intent) {
+ if (intents == null)
+ return false;
+ return Arrays.asList(intents).contains(intent);
+ }
+
+ /**
+ * @since 3.9
+ */
+ public static boolean containsPrivateIntent(String[] intents) {
+ return containsIntent(intents, PRIVATE_INTENT);
+ }
+
+ /**
+ * @since 3.9
+ */
+ public static boolean containsPrivateIntent(Map<String, ?> properties) {
+ return containsPrivateIntent(getContainerIntents(properties));
+ }
+
+ /**
+ * @since 3.9
+ */
+ public static String[] getStringArrayProperty(Map properties, String key) {
+ if (properties == null)
+ return null;
+ Object value = properties.get(key);
+ List<String> r = new ArrayList<String>();
+ if (value == null)
+ r = Collections.EMPTY_LIST;
+
+ if (value instanceof String)
+ r = Collections.singletonList((String) value);
+
+ if (value instanceof String[]) {
+ String[] values = (String[]) value;
+ for (int i = 0; i < values.length; i++) {
+ if (values[i] != null)
+ r.add(values[i]);
+ }
+ }
+
+ if (value instanceof Collection) {
+ Collection values = (Collection) value;
+ List result = new ArrayList(values.size());
+ for (Iterator iter = values.iterator(); iter.hasNext();) {
+ Object v = iter.next();
+ if (v instanceof String) {
+ result.add(v);
+ }
+ }
+ }
+ return (r.size() == 0) ? null : r.toArray(new String[r.size()]);
+ }
+
+ /**
+ * @since 3.9
+ */
+ public static void checkPrivate(InetAddress inetAddress) throws ContainerIntentException {
+ if (!inetAddress.isSiteLocalAddress())
+ throw new ContainerIntentException(PRIVATE_INTENT, "Address " + inetAddress + " is not private"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * @since 3.9
+ */
+ public static void checkPrivate(String hostname) throws ContainerIntentException {
+ if (hostname == null)
+ throw new ContainerIntentException(PRIVATE_INTENT, "Null hostname cannot be private"); //$NON-NLS-1$
+
+ InetAddress ia = null;
+ if (hostname.equals("localhost") || hostname.equals("127.0.0.1")) { //$NON-NLS-1$ //$NON-NLS-2$
+ try {
+ ia = InetAddress.getLocalHost();
+ } catch (UnknownHostException e) {
+ throw new ContainerIntentException(PRIVATE_INTENT, "Could not get localhost inetaddress", e); //$NON-NLS-1$
+ }
+ } else {
+ try {
+ ia = InetAddress.getByName(hostname);
+ } catch (UnknownHostException e) {
+ throw new ContainerIntentException(PRIVATE_INTENT, "Could not get address for hostname: " + hostname); //$NON-NLS-1$
+ }
+ }
+ checkPrivate(ia);
+ }
+
+ /**
+ * @since 3.9
+ */
+ public static void checkPrivate(ID serverID) throws ContainerIntentException {
+ String name = serverID.getName();
+ try {
+ checkPrivate(new URI(name).getHost());
+ } catch (URISyntaxException e) {
+ throw new ContainerIntentException(PRIVATE_INTENT, "Could not get hostname for serverID name: " + name); //$NON-NLS-1$
+ }
+ }
+}
diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/provider/ContainerIntentException.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/provider/ContainerIntentException.java
new file mode 100644
index 000000000..bc1ce5e8b
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/provider/ContainerIntentException.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+* Copyright (c) 2018 Composent, Inc. and others. All rights reserved. This
+* program and the accompanying materials are made available under the terms of
+* the Eclipse Public License v1.0 which accompanies this distribution, and is
+* available at http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* Composent, Inc. - initial API and implementation
+******************************************************************************/
+package org.eclipse.ecf.core.provider;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.ecf.core.ContainerCreateException;
+
+/**
+ * @since 3.9
+ */
+public class ContainerIntentException extends ContainerCreateException {
+
+ private String intentName;
+
+ public ContainerIntentException(String intentName, IStatus status) {
+ super(status);
+ this.intentName = intentName;
+ }
+
+ public ContainerIntentException(String intentName, String message, Throwable cause) {
+ super(message, cause);
+ this.intentName = intentName;
+ }
+
+ public ContainerIntentException(String intentName, String message) {
+ super(message);
+ this.intentName = intentName;
+ }
+
+ private static final long serialVersionUID = -2199528348944072112L;
+
+ public String getIntentName() {
+ return this.intentName;
+ }
+
+}

Back to the top