Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2018-03-16 17:13:02 -0400
committerslewis2018-03-16 17:13:02 -0400
commit41c205972c34961c27c818d43499ac0e10e7ed81 (patch)
treebc2af6a55ea658a87c19f980b6e7aad2c02082e0 /framework
parent6c57bb3fe5bdd051d9d30ba14a9684b3f9ed6f9a (diff)
downloadorg.eclipse.ecf-41c205972c34961c27c818d43499ac0e10e7ed81.tar.gz
org.eclipse.ecf-41c205972c34961c27c818d43499ac0e10e7ed81.tar.xz
org.eclipse.ecf-41c205972c34961c27c818d43499ac0e10e7ed81.zip
Additional fixes for bug
https://bugs.eclipse.org/bugs/show_bug.cgi?id=532205 Simplified API for checking osgi intents in container creation Change-Id: I0000000000000000000000000000000000000000
Diffstat (limited to 'framework')
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/RemoteServiceContainerInstantiator.java69
1 files changed, 44 insertions, 25 deletions
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/RemoteServiceContainerInstantiator.java b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/RemoteServiceContainerInstantiator.java
index b2954ff68..131034d72 100644
--- a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/RemoteServiceContainerInstantiator.java
+++ b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/provider/RemoteServiceContainerInstantiator.java
@@ -8,6 +8,7 @@
******************************************************************************/
package org.eclipse.ecf.remoteservice.provider;
+import java.net.URI;
import java.util.*;
import org.eclipse.ecf.core.*;
import org.eclipse.ecf.core.provider.*;
@@ -131,7 +132,7 @@ public abstract class RemoteServiceContainerInstantiator extends BaseContainerIn
/**
* @since 8.13
*/
- public static String[] addSupportedIntent(String intent, String[] currentSupportedIntents) {
+ protected static String[] addSupportedIntent(String intent, String[] currentSupportedIntents) {
if (intent == null)
return currentSupportedIntents;
List<String> results = (currentSupportedIntents == null) ? new ArrayList<String>() : new ArrayList<String>(Arrays.asList(currentSupportedIntents));
@@ -142,7 +143,7 @@ public abstract class RemoteServiceContainerInstantiator extends BaseContainerIn
/**
* @since 8.13
*/
- public static String[] removeSupportedIntent(String intent, String[] currentSupportedIntents) {
+ protected static String[] removeSupportedIntent(String intent, String[] currentSupportedIntents) {
if (intent == null)
return currentSupportedIntents;
List<String> results = (currentSupportedIntents == null) ? new ArrayList<String>() : new ArrayList<String>(Arrays.asList(currentSupportedIntents));
@@ -153,40 +154,35 @@ public abstract class RemoteServiceContainerInstantiator extends BaseContainerIn
/**
* @since 8.13
*/
- public void checkPrivateHostname(ContainerTypeDescription description, String hostname) throws ContainerIntentException {
+ protected void checkPrivate(ContainerTypeDescription description, String hostname) throws ContainerIntentException {
ContainerInstantiatorUtils.checkPrivate(hostname);
}
/**
* @since 8.13
*/
- protected List<String> getServiceIntents(ContainerTypeDescription description, Map<String, ?> properties) {
- if (description != null) {
- String[] supportedIntents = getSupportedIntents(description);
- if (supportedIntents != null && properties != null)
- return EndpointDescriptionPropertiesUtil.getStringPlusProperty(properties, Constants.OSGI_SERVICE_INTENTS);
- }
- return null;
+ protected List<String> getServiceIntents(Map<String, ?> properties) {
+ return EndpointDescriptionPropertiesUtil.getStringPlusProperty(properties, Constants.OSGI_SERVICE_INTENTS);
}
/**
* @since 8.13
*/
- @SuppressWarnings("unused")
- public boolean checkAsyncIntent(ContainerTypeDescription description, String hostname, Map<String, ?> properties) throws ContainerIntentException {
- List<String> serviceIntents = getServiceIntents(description, properties);
- if (serviceIntents != null && serviceIntents.contains(Constants.OSGI_PRIVATE_INTENT))
- return true;
+ protected boolean checkIntentSupported(ContainerTypeDescription description, String intent) {
+ String[] supportedIntents = getSupportedIntents(description);
+ if (supportedIntents != null)
+ return Arrays.asList(supportedIntents).contains(intent);
return false;
}
/**
* @since 8.13
*/
- public boolean checkPrivateIntent(ContainerTypeDescription description, String hostname, Map<String, ?> properties) throws ContainerIntentException {
- List<String> serviceIntents = getServiceIntents(description, properties);
- if (serviceIntents != null && serviceIntents.contains(Constants.OSGI_PRIVATE_INTENT)) {
- checkPrivateHostname(description, hostname);
+ protected boolean checkAsyncIntent(ContainerTypeDescription description, Map<String, ?> properties) throws ContainerIntentException {
+ List<String> serviceIntents = getServiceIntents(properties);
+ if (serviceIntents.contains(Constants.OSGI_ASYNC_INTENT)) {
+ if (!checkIntentSupported(description, Constants.OSGI_ASYNC_INTENT))
+ throw new ContainerIntentException(Constants.OSGI_ASYNC_INTENT, "Intent not supported by distribution provider=" + description.getName()); //$NON-NLS-1$
return true;
}
return false;
@@ -195,11 +191,25 @@ public abstract class RemoteServiceContainerInstantiator extends BaseContainerIn
/**
* @since 8.13
*/
- public boolean checkConfidentialIntent(ContainerTypeDescription description, String uri, Map<String, ?> properties) throws ContainerIntentException {
- List<String> serviceIntents = getServiceIntents(description, properties);
- if (serviceIntents != null && serviceIntents.contains(Constants.OSGI_CONFIDENTIAL_INTENT)) {
- checkConfidentialURI(description, uri);
- return true;
+ protected boolean checkPrivateIntent(ContainerTypeDescription description, String hostname, Map<String, ?> properties) throws ContainerIntentException {
+ List<String> serviceIntents = getServiceIntents(properties);
+ if (serviceIntents.contains(Constants.OSGI_PRIVATE_INTENT)) {
+ if (!checkIntentSupported(description, Constants.OSGI_PRIVATE_INTENT))
+ throw new ContainerIntentException(Constants.OSGI_PRIVATE_INTENT, "Not supported by distribution provider=" + description.getName()); //$NON-NLS-1$
+ checkPrivate(description, hostname);
+ }
+ return false;
+ }
+
+ /**
+ * @since 8.13
+ */
+ protected boolean checkConfidentialIntent(ContainerTypeDescription description, String uri, Map<String, ?> properties) throws ContainerIntentException {
+ List<String> serviceIntents = getServiceIntents(properties);
+ if (serviceIntents.contains(Constants.OSGI_CONFIDENTIAL_INTENT)) {
+ if (!checkIntentSupported(description, Constants.OSGI_CONFIDENTIAL_INTENT))
+ throw new ContainerIntentException(Constants.OSGI_CONFIDENTIAL_INTENT, "Intent not supported by distribution provider=" + description.getName()); //$NON-NLS-1$
+ checkConfidential(description, uri);
}
return false;
}
@@ -207,9 +217,18 @@ public abstract class RemoteServiceContainerInstantiator extends BaseContainerIn
/**
* @since 8.13
*/
- public void checkConfidentialURI(ContainerTypeDescription description, String uri) throws ContainerIntentException {
+ protected void checkConfidential(ContainerTypeDescription description, String uri) throws ContainerIntentException {
if (uri != null && uri.startsWith("https")) //$NON-NLS-1$
return;
throw new ContainerIntentException(Constants.OSGI_CONFIDENTIAL_INTENT, "provider=" + description.getName() + " failed confientiality check for uri=" + uri); //$NON-NLS-1$ //$NON-NLS-2$
}
+
+ /**
+ * @since 8.13
+ */
+ protected void checkOSGIIntents(ContainerTypeDescription description, URI uri, Map<String, ?> properties) throws ContainerIntentException {
+ checkAsyncIntent(description, properties);
+ checkPrivateIntent(description, uri.getHost(), properties);
+ checkConfidentialIntent(description, uri.toString(), properties);
+ }
}

Back to the top