Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2013-01-18 06:21:48 +0000
committerslewis2013-01-18 06:21:48 +0000
commit15d0cf001a6ca546eb08955b67a3fe7b9b51494e (patch)
tree75a4414a4a0833d98f760a8bcd4494e5ae23c2ad /server-side
parent0608a7e55141ec9db9555c2f40da24ec91b0916b (diff)
parent3c625760d319f471800ba5b2d53c056d9afe8e27 (diff)
downloadorg.eclipse.ecf-15d0cf001a6ca546eb08955b67a3fe7b9b51494e.tar.gz
org.eclipse.ecf-15d0cf001a6ca546eb08955b67a3fe7b9b51494e.tar.xz
org.eclipse.ecf-15d0cf001a6ca546eb08955b67a3fe7b9b51494e.zip
Additions to support ssl-based transport
Diffstat (limited to 'server-side')
-rw-r--r--server-side/bundles/org.eclipse.ecf.server.generic/META-INF/MANIFEST.MF2
-rw-r--r--server-side/bundles/org.eclipse.ecf.server.generic/plugin.xml44
-rw-r--r--server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/internal/server/generic/GenericServerContainerGroupFactory.java4
-rw-r--r--server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/internal/server/generic/SSLGenericServerContainerGroupFactory.java125
-rw-r--r--server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/IGenericServerContainerGroupFactory.java9
-rw-r--r--server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/SSLGenericServerContainer.java52
-rw-r--r--server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/SSLGenericServerContainerGroup.java186
-rw-r--r--server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/SimpleSSLGenericServer.java31
-rw-r--r--server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/AbstractSSLGenericClientApplication.java71
-rw-r--r--server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/AbstractSSLGenericServerApplication.java151
-rw-r--r--server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/SSLGenericClientApplication.java91
-rw-r--r--server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/SSLGenericClientJavaApplication.java43
-rw-r--r--server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/SSLGenericServer.java230
-rw-r--r--server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/SSLGenericServerApplication.java73
-rw-r--r--server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/SSLGenericServerJavaApplication.java31
-rw-r--r--server-side/bundles/org.eclipse.ecf.server.generic/sslserver.xml5
16 files changed, 1147 insertions, 1 deletions
diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/META-INF/MANIFEST.MF b/server-side/bundles/org.eclipse.ecf.server.generic/META-INF/MANIFEST.MF
index bd9ab0ed8..1a973a5be 100644
--- a/server-side/bundles/org.eclipse.ecf.server.generic/META-INF/MANIFEST.MF
+++ b/server-side/bundles/org.eclipse.ecf.server.generic/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %plugin.name
Bundle-SymbolicName: org.eclipse.ecf.server.generic;singleton:=true
-Bundle-Version: 5.1.0.qualifier
+Bundle-Version: 6.0.0.qualifier
Bundle-Activator: org.eclipse.ecf.internal.server.generic.Activator
Bundle-Vendor: %plugin.provider
Bundle-Localization: plugin
diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/plugin.xml b/server-side/bundles/org.eclipse.ecf.server.generic/plugin.xml
index 44fa9bc6d..857b86e3e 100644
--- a/server-side/bundles/org.eclipse.ecf.server.generic/plugin.xml
+++ b/server-side/bundles/org.eclipse.ecf.server.generic/plugin.xml
@@ -11,6 +11,15 @@
<adapter type="org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter"/>
</factory>
</extension>
+
+ <extension
+ point="org.eclipse.core.runtime.adapters">
+ <factory
+ adaptableType="org.eclipse.ecf.server.generic.SSLGenericServerContainer"
+ class="org.eclipse.ecf.provider.remoteservice.generic.RemoteServiceContainerAdapterFactory">
+ <adapter type="org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter"/>
+ </factory>
+ </extension>
<extension
id="Server"
@@ -25,6 +34,18 @@
</extension>
<extension
+ id="SecureServer"
+ point="org.eclipse.core.runtime.applications">
+ <application
+ cardinality="*"
+ thread="any"
+ visible="true">
+ <run
+ class="org.eclipse.ecf.server.generic.app.SSLGenericServerApplication"/>
+ </application>
+ </extension>
+
+ <extension
id="Client"
point="org.eclipse.core.runtime.applications">
<application
@@ -36,6 +57,17 @@
</application>
</extension>
<extension
+ id="SecureClient"
+ point="org.eclipse.core.runtime.applications">
+ <application
+ cardinality="*"
+ thread="any"
+ visible="true">
+ <run
+ class="org.eclipse.ecf.server.generic.app.SSLGenericClientApplication"/>
+ </application>
+ </extension>
+ <extension
id="GenericClientApplication"
point="org.eclipse.core.runtime.applications">
<application
@@ -47,4 +79,16 @@
</application>
</extension>
+ <extension
+ id="SSLGenericClientApplication"
+ point="org.eclipse.core.runtime.applications">
+ <application
+ thread="any"
+ visible="true">
+ <run
+ class="org.eclipse.ecf.server.generic.app.SSLGenericClientApplication">
+ </run>
+ </application>
+ </extension>
+
</plugin>
diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/internal/server/generic/GenericServerContainerGroupFactory.java b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/internal/server/generic/GenericServerContainerGroupFactory.java
index dc2c5c456..67ac827ba 100644
--- a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/internal/server/generic/GenericServerContainerGroupFactory.java
+++ b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/internal/server/generic/GenericServerContainerGroupFactory.java
@@ -118,4 +118,8 @@ public class GenericServerContainerGroupFactory implements IGenericServerContain
return (IGenericServerContainerGroup) serverContainerGroups.remove(scgdata);
}
}
+
+ public boolean isSecureTransport() {
+ return false;
+ }
}
diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/internal/server/generic/SSLGenericServerContainerGroupFactory.java b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/internal/server/generic/SSLGenericServerContainerGroupFactory.java
new file mode 100644
index 000000000..9653b12ed
--- /dev/null
+++ b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/internal/server/generic/SSLGenericServerContainerGroupFactory.java
@@ -0,0 +1,125 @@
+/*******************************************************************************
+* Copyright (c) 2010 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.internal.server.generic;
+
+import java.util.*;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.ecf.server.generic.*;
+
+public class SSLGenericServerContainerGroupFactory implements IGenericServerContainerGroupFactory {
+
+ class SCGData {
+ private String hostname;
+ private int port;
+
+ SCGData(String hostname, int port) {
+ Assert.isNotNull(hostname);
+ Assert.isTrue(port > 0);
+ this.hostname = hostname;
+ this.port = port;
+ }
+
+ public String getHostname() {
+ return hostname;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public boolean equals(Object other) {
+ if (!(other instanceof SCGData))
+ return false;
+ SCGData o = (SCGData) other;
+ if (this.hostname.equals(o.hostname) && this.port == o.port)
+ return true;
+ return false;
+ }
+
+ public int hashCode() {
+ return this.hostname.hashCode() ^ this.port;
+ }
+ }
+
+ private Hashtable serverContainerGroups = new Hashtable();
+
+ public IGenericServerContainerGroup createContainerGroup(String hostname, int port, Map defaultContainerProperties) throws GenericServerContainerGroupCreateException {
+ synchronized (serverContainerGroups) {
+ SCGData scgdata = new SCGData(hostname, port);
+ if (serverContainerGroups.contains(scgdata))
+ throw new GenericServerContainerGroupCreateException("Cannot container group hostname=" + hostname + " port=" + port + " already exists"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ IGenericServerContainerGroup scg = createGenericServerContainerGroup(scgdata, defaultContainerProperties);
+ serverContainerGroups.put(scgdata, scg);
+ return scg;
+ }
+ }
+
+ /**
+ * @throws GenericServerContainerGroupCreateException
+ */
+ protected IGenericServerContainerGroup createGenericServerContainerGroup(SCGData scgdata, Map defaultContainerProperties) throws GenericServerContainerGroupCreateException {
+ return new SSLGenericServerContainerGroup(scgdata.getHostname(), scgdata.getPort(), defaultContainerProperties);
+ }
+
+ public IGenericServerContainerGroup createContainerGroup(String hostname, int port) throws GenericServerContainerGroupCreateException {
+ return createContainerGroup(hostname, port, null);
+ }
+
+ public IGenericServerContainerGroup createContainerGroup(String hostname) throws GenericServerContainerGroupCreateException {
+ return createContainerGroup(hostname, DEFAULT_SECURE_PORT);
+ }
+
+ public void close() {
+ synchronized (serverContainerGroups) {
+ for (Iterator i = serverContainerGroups.keySet().iterator(); i.hasNext();) {
+ SCGData scgdata = (SCGData) i.next();
+ IGenericServerContainerGroup scg = (IGenericServerContainerGroup) serverContainerGroups.get(scgdata);
+ // call close
+ scg.close();
+ }
+ }
+ serverContainerGroups.clear();
+ }
+
+ public IGenericServerContainerGroup getContainerGroup(String hostname, int port) {
+ if (hostname == null)
+ return null;
+ SCGData scgdata = new SCGData(hostname, port);
+ synchronized (serverContainerGroups) {
+ return (IGenericServerContainerGroup) serverContainerGroups.get(scgdata);
+ }
+ }
+
+ public IGenericServerContainerGroup[] getContainerGroups() {
+ List results = new ArrayList();
+ synchronized (serverContainerGroups) {
+ for (Iterator i = serverContainerGroups.keySet().iterator(); i.hasNext();) {
+ SCGData scgdata = (SCGData) i.next();
+ IGenericServerContainerGroup gscg = (IGenericServerContainerGroup) serverContainerGroups.get(scgdata);
+ if (gscg != null)
+ results.add(gscg);
+ }
+ }
+ return (IGenericServerContainerGroup[]) results.toArray(new IGenericServerContainerGroup[] {});
+ }
+
+ public IGenericServerContainerGroup removeContainerGroup(String hostname, int port) {
+ if (hostname == null)
+ return null;
+ SCGData scgdata = new SCGData(hostname, port);
+ synchronized (serverContainerGroups) {
+ return (IGenericServerContainerGroup) serverContainerGroups.remove(scgdata);
+ }
+ }
+
+ public boolean isSecureTransport() {
+ return true;
+ }
+}
diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/IGenericServerContainerGroupFactory.java b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/IGenericServerContainerGroupFactory.java
index d0191fef4..ad43537c7 100644
--- a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/IGenericServerContainerGroupFactory.java
+++ b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/IGenericServerContainerGroupFactory.java
@@ -25,6 +25,11 @@ public interface IGenericServerContainerGroupFactory {
public int DEFAULT_PORT = 3282;
/**
+ * @since 6.0
+ */
+ public int DEFAULT_SECURE_PORT = 4282;
+
+ /**
* Create a new container group given a hostname, port, and a Map of default container properties.
* @param hostname the hostname associated with the new container group. Must not be <code>null</code>.
* @param port the port that the new container group will listen on (once {@link IGenericServerContainerGroup#startListening()}
@@ -88,4 +93,8 @@ public interface IGenericServerContainerGroupFactory {
*/
public IGenericServerContainerGroup removeContainerGroup(String hostname, int port);
+ /**
+ * @since 6.0
+ */
+ public boolean isSecureTransport();
}
diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/SSLGenericServerContainer.java b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/SSLGenericServerContainer.java
new file mode 100644
index 000000000..b4cd584ef
--- /dev/null
+++ b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/SSLGenericServerContainer.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+* Copyright (c) 2009 EclipseSource 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:
+* EclipseSource - initial API and implementation
+******************************************************************************/
+/**
+ *
+ */
+package org.eclipse.ecf.server.generic;
+
+import org.eclipse.ecf.core.IContainerListener;
+import org.eclipse.ecf.core.events.*;
+import org.eclipse.ecf.core.sharedobject.ISharedObjectContainerConfig;
+import org.eclipse.ecf.provider.generic.SSLServerSOContainer;
+import org.eclipse.ecf.provider.generic.SSLServerSOContainerGroup;
+
+/**
+ *
+ * @since 5.2
+ *
+ */
+public class SSLGenericServerContainer extends SSLServerSOContainer {
+
+ final AbstractSSLGenericServer abstractGenericServer;
+
+ private IContainerListener departedListener = new IContainerListener() {
+ public void handleEvent(IContainerEvent event) {
+ if (event instanceof IContainerDisconnectedEvent) {
+ IContainerDisconnectedEvent de = (IContainerDisconnectedEvent) event;
+ SSLGenericServerContainer.this.abstractGenericServer.handleDisconnect(de.getTargetID());
+ } else if (event instanceof IContainerEjectedEvent) {
+ IContainerEjectedEvent de = (IContainerEjectedEvent) event;
+ SSLGenericServerContainer.this.abstractGenericServer.handleEject(de.getTargetID());
+ }
+ }
+ };
+
+ public SSLGenericServerContainer(AbstractSSLGenericServer abstractGenericServer, ISharedObjectContainerConfig config, SSLServerSOContainerGroup listener, String path, int keepAlive) {
+ super(config, listener, path, keepAlive);
+ this.abstractGenericServer = abstractGenericServer;
+ addListener(departedListener);
+ }
+
+ public void dispose() {
+ removeListener(departedListener);
+ super.dispose();
+ }
+} \ No newline at end of file
diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/SSLGenericServerContainerGroup.java b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/SSLGenericServerContainerGroup.java
new file mode 100644
index 000000000..27e5ebf43
--- /dev/null
+++ b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/SSLGenericServerContainerGroup.java
@@ -0,0 +1,186 @@
+/*******************************************************************************
+* Copyright (c) 2010 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.server.generic;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.*;
+import org.eclipse.ecf.core.*;
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.identity.IDFactory;
+import org.eclipse.ecf.core.sharedobject.ISharedObjectContainer;
+import org.eclipse.ecf.internal.server.generic.Activator;
+import org.eclipse.ecf.provider.generic.*;
+
+/**
+ * @since 6.0
+ */
+public class SSLGenericServerContainerGroup implements IGenericServerContainerGroup {
+
+ private SSLGenericServerSOContainerGroup serverGroup;
+ private Map defaultContainerProperties;
+
+ class SSLGenericServerSOContainerGroup extends SSLServerSOContainerGroup {
+
+ public SSLGenericServerSOContainerGroup(String name, int port) {
+ super(name, port);
+ }
+
+ public Map getMap() {
+ return map;
+ }
+ }
+
+ public SSLGenericServerContainerGroup(String hostname, int port, Map defaultContainerProperties) {
+ this.serverGroup = new SSLGenericServerSOContainerGroup(hostname, port);
+ this.defaultContainerProperties = defaultContainerProperties;
+ }
+
+ private String getHost() {
+ return serverGroup.getName();
+ }
+
+ private int getPort() {
+ return serverGroup.getPort();
+ }
+
+ public Map getContainers() {
+ Map result = new HashMap();
+ Map lock = serverGroup.getMap();
+ synchronized (lock) {
+ for (Iterator i = lock.keySet().iterator(); i.hasNext();) {
+ String key = (String) i.next();
+ result.put(key, lock.get(key));
+ }
+ }
+ return result;
+ }
+
+ public ISharedObjectContainer createContainer(String path, int keepAlive, Map properties) throws ContainerCreateException {
+ if (path == null)
+ throw new ContainerCreateException("Path for new container cannot be null"); //$NON-NLS-1$
+ Map lock = serverGroup.getMap();
+ ISharedObjectContainer newContainer = null;
+ synchronized (lock) {
+ SSLServerSOContainer existing = (SSLServerSOContainer) lock.get(path);
+ if (existing != null)
+ throw new ContainerCreateException("Container with path=" + path + " already exists"); //$NON-NLS-1$ //$NON-NLS-2$
+ // create container
+ newContainer = createGenericServerContainer(path, keepAlive, properties);
+ // add To container manager
+ addNewContainerToContainerManager(newContainer);
+ }
+ return newContainer;
+ }
+
+ public ISharedObjectContainer createContainer(String path, int keepAlive) throws ContainerCreateException {
+ return createContainer(path, keepAlive, null);
+ }
+
+ private void addNewContainerToContainerManager(ISharedObjectContainer container) {
+ IContainerManager containerManager = Activator.getDefault().getContainerManager();
+ if (containerManager != null) {
+ ContainerTypeDescription ctd = containerManager.getContainerFactory().getDescriptionByName("ecf.generic.server"); //$NON-NLS-1$
+ containerManager.addContainer(container, ctd);
+ }
+ }
+
+ private void removeContainerFromContainerManager(ISharedObjectContainer container) {
+ IContainerManager containerManager = Activator.getDefault().getContainerManager();
+ if (containerManager != null) {
+ containerManager.removeContainer(container);
+ }
+ }
+
+ public ISharedObjectContainer createContainer(String path) throws ContainerCreateException {
+ return createContainer(path, IGenericServerContainerGroup.DEFAULT_KEEPALIVE);
+ }
+
+ /**
+ * @since 5.1
+ */
+ protected SSLGenericServerSOContainerGroup getServerGroup() {
+ return serverGroup;
+ }
+
+ protected SSLServerSOContainer createGenericServerContainer(String path, int keepAlive, Map properties) throws ContainerCreateException {
+ try {
+ return new SSLServerSOContainer(new SOContainerConfig(createGenericServerID(path, properties), createGenericServerProperties(path, properties)), getServerGroup(), path, keepAlive);
+ } catch (Exception e) {
+ throw new ContainerCreateException("Unexpected exception creating generic server container path=" + path, e); //$NON-NLS-1$
+ }
+ }
+
+ protected Map createGenericServerProperties(String path, Map properties) {
+ return (properties == null) ? defaultContainerProperties : properties;
+ }
+
+ protected ID createGenericServerID(String path, Map properties) throws ContainerCreateException {
+ if (!path.startsWith("/")) //$NON-NLS-1$
+ throw new ContainerCreateException("Path must start with '/'"); //$NON-NLS-1$
+ String serverIDPrefix = createGenericServerIDPrefix();
+ return IDFactory.getDefault().createStringID(serverIDPrefix + path);
+ }
+
+ private String createGenericServerIDPrefix() {
+ return SSLServerSOContainer.DEFAULT_PROTOCOL + "://" + getHost() + ":" + getPort(); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public ISharedObjectContainer getContainer(String path) {
+ return serverGroup.get(path);
+ }
+
+ public ISharedObjectContainer removeContainer(String path) {
+ return serverGroup.remove(path);
+ }
+
+ public void startListening() throws IOException {
+ Map lock = serverGroup.getMap();
+ synchronized (lock) {
+ serverGroup.putOnTheAir();
+ }
+ }
+
+ public boolean isListening() {
+ return serverGroup.isOnTheAir();
+ }
+
+ public void stopListening() {
+ Map lock = serverGroup.getMap();
+ synchronized (lock) {
+ serverGroup.takeOffTheAir();
+ }
+ }
+
+ public void close() {
+ Map lock = serverGroup.getMap();
+ synchronized (lock) {
+ for (Iterator i = lock.keySet().iterator(); i.hasNext();) {
+ SSLServerSOContainer container = (SSLServerSOContainer) removeContainer((String) i.next());
+ removeContainerFromContainerManager(container);
+ if (container != null) {
+ container.dispose();
+ }
+ }
+ serverGroup.takeOffTheAir();
+ }
+ }
+
+ public URI getGroupEndpoint() {
+ try {
+ return new URI(createGenericServerIDPrefix());
+ } catch (URISyntaxException e) {
+ // should not happen
+ return null;
+ }
+ }
+
+}
diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/SimpleSSLGenericServer.java b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/SimpleSSLGenericServer.java
new file mode 100644
index 000000000..00b40ad9d
--- /dev/null
+++ b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/SimpleSSLGenericServer.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+* Copyright (c) 2009 EclipseSource 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:
+* EclipseSource - initial API and implementation
+******************************************************************************/
+package org.eclipse.ecf.server.generic;
+
+import org.eclipse.ecf.core.identity.ID;
+
+/**
+ * @since 6.0
+ */
+public class SimpleSSLGenericServer extends AbstractSSLGenericServer {
+
+ public SimpleSSLGenericServer(String host, int port) {
+ super(host, port);
+ }
+
+ protected void handleDisconnect(ID targetId) {
+ // nothing
+ }
+
+ protected void handleEject(ID targetId) {
+ // nothing
+ }
+
+}
diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/AbstractSSLGenericClientApplication.java b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/AbstractSSLGenericClientApplication.java
new file mode 100644
index 000000000..401fe7431
--- /dev/null
+++ b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/AbstractSSLGenericClientApplication.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+* Copyright (c) 2013 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.server.generic.app;
+
+import org.eclipse.ecf.core.ContainerConnectException;
+import org.eclipse.ecf.core.ContainerCreateException;
+import org.eclipse.ecf.core.identity.IDFactory;
+import org.eclipse.ecf.core.sharedobject.ISharedObjectContainer;
+import org.eclipse.ecf.provider.generic.SSLServerSOContainer;
+
+/**
+ * @since 6.0
+ */
+public abstract class AbstractSSLGenericClientApplication {
+
+ protected String connectTarget;
+ protected ISharedObjectContainer clientContainer;
+ protected int waitTime = 40000;
+ /**
+ * @since 5.1
+ */
+ protected String clientId = null;
+ /**
+ * @since 5.1
+ */
+ protected String password = null;
+
+ protected abstract ISharedObjectContainer createContainer() throws ContainerCreateException;
+
+ protected void processArguments(String[] args) {
+ connectTarget = SSLServerSOContainer.getDefaultServerURL();
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].equals("-connectTarget")) { //$NON-NLS-1$
+ connectTarget = args[i + 1];
+ i++;
+ }
+ if (args[i].equals("-waitTime")) { //$NON-NLS-1$
+ waitTime = new Integer(args[i + 1]).intValue();
+ i++;
+ }
+ if (args[i].equals("-clientId")) { //$NON-NLS-1$
+ clientId = args[i + 1];
+ }
+ if (args[i].equals("-connectPassword")) { //$NON-NLS-1$
+ password = args[i + 1];
+ }
+ }
+ }
+
+ protected void initialize() throws ContainerCreateException {
+ clientContainer = createContainer();
+ }
+
+ protected void connect() throws ContainerConnectException {
+ clientContainer.connect(IDFactory.getDefault().createStringID(connectTarget), null);
+ }
+
+ protected void dispose() {
+ if (clientContainer != null) {
+ clientContainer.dispose();
+ clientContainer = null;
+ }
+ }
+}
diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/AbstractSSLGenericServerApplication.java b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/AbstractSSLGenericServerApplication.java
new file mode 100644
index 000000000..51492580e
--- /dev/null
+++ b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/AbstractSSLGenericServerApplication.java
@@ -0,0 +1,151 @@
+/*******************************************************************************
+* Copyright (c) 2013 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.server.generic.app;
+
+import java.io.*;
+import java.net.*;
+import java.security.PermissionCollection;
+import java.util.Iterator;
+import java.util.List;
+import org.eclipse.ecf.core.IContainerListener;
+import org.eclipse.ecf.core.events.*;
+import org.eclipse.ecf.core.identity.*;
+import org.eclipse.ecf.core.security.IConnectHandlerPolicy;
+import org.eclipse.ecf.core.sharedobject.ISharedObjectContainerGroupManager;
+import org.eclipse.ecf.provider.generic.*;
+
+/**
+ * @since 6.0
+ */
+public abstract class AbstractSSLGenericServerApplication {
+
+ protected SSLServerSOContainerGroup[] serverGroups;
+
+ protected String configURL;
+ protected String serverName;
+
+ static class SysOutConnectHandlerPolicy implements IConnectHandlerPolicy {
+ public PermissionCollection checkConnect(Object addr, ID fromID, ID targetID, String targetGroup, Object joinData) throws Exception {
+ System.out.println("Client Connect Addr=" + addr + ";ID=" + fromID + ";Group=" + targetGroup); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return null;
+ }
+
+ public void refresh() {
+ // do nothing
+ }
+ }
+
+ static class ContainerListener implements IContainerListener {
+ public void handleEvent(IContainerEvent event) {
+ if (event instanceof IContainerDisconnectedEvent) {
+ System.out.println("Client id=" + ((IContainerDisconnectedEvent) event).getTargetID() + " disconnected."); //$NON-NLS-1$ //$NON-NLS-2$
+ } else if (event instanceof IContainerEjectedEvent) {
+ System.out.println("Client id=" + ((IContainerEjectedEvent) event).getTargetID() + " ejected."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ }
+
+ protected void processArguments(String[] args) {
+ configURL = null;
+ serverName = SSLServerSOContainer.getDefaultServerURL();
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].equals("-configURL")) { //$NON-NLS-1$
+ configURL = args[i + 1];
+ i++;
+ } else if (args[i].equals("-serverName")) { //$NON-NLS-1$
+ serverName = args[i + 1];
+ i++;
+ }
+ }
+ }
+
+ protected void initialize() throws Exception {
+ List connectors = null;
+ if (configURL != null) {
+ InputStream ins = null;
+ try {
+ try {
+ ins = new URL(configURL).openStream();
+ } catch (MalformedURLException e) {
+ // If it's not an URL, just try to load via file
+ ins = new FileInputStream(configURL);
+ }
+ // read connectors from input stream via ServerConfigParser
+ connectors = new ServerConfigParser().load(ins);
+ } finally {
+ if (ins != null)
+ ins.close();
+ }
+ initializeFromConnectors(connectors);
+ } else
+ initializeSingleServer();
+ }
+
+ protected void initializeSingleServer() throws IOException, URISyntaxException {
+ java.net.URI anURL = new java.net.URI(serverName);
+ int port = anURL.getPort();
+ if (port == -1)
+ port = SSLServerSOContainer.DEFAULT_PORT;
+ String name = anURL.getPath();
+ if (name == null)
+ name = SSLServerSOContainer.DEFAULT_NAME;
+ serverGroups = new SSLServerSOContainerGroup[1];
+ // Setup server group
+ serverGroups[0] = new SSLServerSOContainerGroup(anURL.getPort());
+ SSLServerSOContainer server = createServerContainer(serverName, serverGroups[0], name, TCPServerSOContainer.DEFAULT_KEEPALIVE);
+
+ setupServerContainer(server);
+ // Then put the new server on the air
+ serverGroups[0].putOnTheAir();
+ }
+
+ protected void initializeFromConnectors(List connectors) throws IOException {
+ if (connectors == null)
+ return;
+ serverGroups = new SSLServerSOContainerGroup[connectors.size()];
+ int j = 0;
+ for (Iterator i = connectors.iterator(); i.hasNext();) {
+ Connector connector = (Connector) i.next();
+ serverGroups[j] = new SSLServerSOContainerGroup(connector.getHostname(), connector.getPort());
+ List groups = connector.getGroups();
+ for (Iterator g = groups.iterator(); g.hasNext();) {
+ NamedGroup group = (NamedGroup) g.next();
+ SSLServerSOContainer container = createServerContainer(group.getIDForGroup(), serverGroups[j], group.getName(), connector.getTimeout());
+ setupServerContainer(container);
+ }
+ serverGroups[j].putOnTheAir();
+ j++;
+ }
+ }
+
+ protected SSLServerSOContainer createServerContainer(String id, SSLServerSOContainerGroup group, String path, int keepAlive) throws IDCreateException {
+ return new SSLServerSOContainer(new SOContainerConfig(IDFactory.getDefault().createStringID(id)), group, path, keepAlive);
+ }
+
+ protected void setupServerContainer(SSLServerSOContainer container) {
+ // Setup connect policy
+ ((ISharedObjectContainerGroupManager) container).setConnectPolicy(new SysOutConnectHandlerPolicy());
+ // Setup container listener
+ container.addListener(new ContainerListener());
+ }
+
+ protected void shutdown() {
+ if (serverGroups != null) {
+ for (int i = 0; i < serverGroups.length; i++) {
+ serverGroups[i].takeOffTheAir();
+ final Iterator iter = serverGroups[i].elements();
+ for (; iter.hasNext();) {
+ ((SSLServerSOContainer) iter.next()).dispose();
+ }
+ }
+ serverGroups = null;
+ }
+ }
+}
diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/SSLGenericClientApplication.java b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/SSLGenericClientApplication.java
new file mode 100644
index 000000000..2aea2b91e
--- /dev/null
+++ b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/SSLGenericClientApplication.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+* Copyright (c) 2013 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.server.generic.app;
+
+import org.eclipse.ecf.core.*;
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.security.IConnectContext;
+import org.eclipse.ecf.core.security.IConnectInitiatorPolicy;
+import org.eclipse.ecf.core.sharedobject.ISharedObjectContainer;
+import org.eclipse.ecf.internal.server.generic.Activator;
+import org.eclipse.ecf.provider.generic.SSLClientSOContainer;
+import org.eclipse.equinox.app.IApplication;
+import org.eclipse.equinox.app.IApplicationContext;
+
+/**
+ * @since 6.0
+ */
+public class SSLGenericClientApplication extends AbstractSSLGenericClientApplication implements IApplication {
+
+ private static final String GENERIC_CLIENT_CONTAINER_TYPE = "ecf.generic.client.secure"; //$NON-NLS-1$
+
+ protected final Object appLock = new Object();
+ protected boolean done = false;
+
+ public Object start(IApplicationContext context) throws Exception {
+ String[] args = getArguments(context);
+ processArguments(args);
+
+ initialize();
+
+ connect();
+
+ waitForDone();
+
+ return IApplication.EXIT_OK;
+ }
+
+ public void stop() {
+ dispose();
+ synchronized (appLock) {
+ done = true;
+ appLock.notifyAll();
+ }
+ }
+
+ protected ISharedObjectContainer createContainer() throws ContainerCreateException {
+ IContainerFactory f = Activator.getDefault().getContainerManager().getContainerFactory();
+ SSLClientSOContainer client = (SSLClientSOContainer) ((clientId == null) ? f.createContainer(GENERIC_CLIENT_CONTAINER_TYPE) : f.createContainer(GENERIC_CLIENT_CONTAINER_TYPE, clientId));
+ if (password != null) {
+ client.setConnectInitiatorPolicy(new IConnectInitiatorPolicy() {
+ public void refresh() {
+ //nothing
+ }
+
+ public Object createConnectData(IContainer container, ID targetID, IConnectContext context) {
+ return password;
+ }
+
+ public int getConnectTimeout() {
+ return 30000;
+ }
+ });
+ }
+ return client;
+ }
+
+ protected void waitForDone() {
+ // then just wait here
+ synchronized (appLock) {
+ while (!done) {
+ try {
+ appLock.wait();
+ } catch (InterruptedException e) {
+ // do nothing
+ }
+ }
+ }
+ }
+
+ protected String[] getArguments(IApplicationContext context) {
+ return (String[]) context.getArguments().get("application.args"); //$NON-NLS-1$
+ }
+
+}
diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/SSLGenericClientJavaApplication.java b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/SSLGenericClientJavaApplication.java
new file mode 100644
index 000000000..ac68ad511
--- /dev/null
+++ b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/SSLGenericClientJavaApplication.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+* Copyright (c) 2013 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.server.generic.app;
+
+import org.eclipse.ecf.core.*;
+import org.eclipse.ecf.core.sharedobject.ISharedObjectContainer;
+import org.eclipse.ecf.provider.generic.SSLGenericContainerInstantiator;
+
+/**
+ * @since 6.0
+ */
+public class SSLGenericClientJavaApplication extends AbstractSSLGenericClientApplication {
+
+ protected ISharedObjectContainer createContainer() throws ContainerCreateException {
+ IContainerFactory containerFactory = ContainerFactory.getDefault();
+ containerFactory.addDescription(new ContainerTypeDescription("ecf.generic.client.secure", new SSLGenericContainerInstantiator(), null)); //$NON-NLS-1$
+ return (ISharedObjectContainer) containerFactory.createContainer("ecf.generic.client.secure"); //$NON-NLS-1$
+ }
+
+ public static void main(String[] args) throws Exception {
+ SSLGenericClientJavaApplication app = new SSLGenericClientJavaApplication();
+ app.processArguments(args);
+ app.initialize();
+ app.connect();
+ // wait for waitTime
+ try {
+ synchronized (app) {
+ app.wait(app.waitTime);
+ }
+ } catch (InterruptedException e) {
+ // nothing
+ }
+ app.dispose();
+ }
+
+}
diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/SSLGenericServer.java b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/SSLGenericServer.java
new file mode 100644
index 000000000..1a5d685bb
--- /dev/null
+++ b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/SSLGenericServer.java
@@ -0,0 +1,230 @@
+/****************************************************************************
+ * Copyright (c) 2007 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.server.generic.app;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.security.PermissionCollection;
+import java.util.*;
+import org.eclipse.ecf.core.identity.*;
+import org.eclipse.ecf.core.security.IConnectHandlerPolicy;
+import org.eclipse.ecf.core.sharedobject.ISharedObjectContainerGroupManager;
+import org.eclipse.ecf.provider.generic.*;
+import org.eclipse.equinox.app.IApplication;
+import org.eclipse.equinox.app.IApplicationContext;
+
+/**
+ * This class controls all aspects of the application's execution
+ * @since 6.0
+ */
+public class SSLGenericServer implements IApplication {
+
+ private static Map serverGroups = new HashMap();
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
+ */
+ public Object start(IApplicationContext context) throws Exception {
+ try {
+ final String[] args = mungeArguments((String[]) context.getArguments().get("application.args")); //$NON-NLS-1$
+ if (args.length == 1 && (args[0].equals("-help") || args[0].equals("-h"))) { //$NON-NLS-1$ //$NON-NLS-2$
+ usage();
+ return IApplication.EXIT_OK;
+ } else if (args.length == 2 && (args[0].equals("-config") || args[0].equals("-c"))) { //$NON-NLS-1$ //$NON-NLS-2$
+ // Setup from configuration file (expected after -c <file>
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(args[1]);
+ setupServerFromConfig(new ServerConfigParser().load(fis));
+ } finally {
+ if (fis != null)
+ fis.close();
+ }
+ } else {
+ String hostname = SSLServerSOContainer.DEFAULT_HOST;
+ int port = SSLServerSOContainer.DEFAULT_PORT;
+ String name = SSLServerSOContainer.DEFAULT_NAME;
+ int keepAlive = SSLServerSOContainer.DEFAULT_KEEPALIVE;
+ switch (args.length) {
+ case 4 :
+ keepAlive = Integer.parseInt(args[3]);
+ case 3 :
+ hostname = args[2];
+ case 2 :
+ name = args[1];
+ if (!name.startsWith("/")) //$NON-NLS-1$
+ name = "/" + name; //$NON-NLS-1$
+ case 1 :
+ port = Integer.parseInt(args[0]);
+ }
+ setupServerFromParameters(hostname, port, name, keepAlive);
+ }
+ synchronized (this) {
+ this.wait();
+ }
+ return IApplication.EXIT_OK;
+ } catch (final Exception e) {
+ stop();
+ throw e;
+ }
+ }
+
+ private void usage() {
+ System.out.println("Usage: eclipse.exe -application " //$NON-NLS-1$
+ + this.getClass().getName() + "[port [groupname [hostname [keepAlive]]]] | [-config|-c <configfile.xml>]"); //$NON-NLS-1$
+ System.out.println(" Examples: eclipse -application org.eclipse.ecf.provider.SSLGenericServer"); //$NON-NLS-1$
+ System.out.println(" eclipse -application org.eclipse.ecf.provider.SSLGenericServer " + 7777); //$NON-NLS-1$
+ System.out.println(" eclipse -application org.eclipse.ecf.provider.SSLGenericServer " + 7777 //$NON-NLS-1$
+ + " mygroup foobarhost.wherever.com 35000"); //$NON-NLS-1$
+ System.out.println(" eclipse -application org.eclipse.ecf.provider.SSLGenericServer -c myconfig.xml"); //$NON-NLS-1$
+
+ }
+
+ /**
+ * @param hostname
+ * @param port
+ * @param name
+ * @param keepAlive
+ */
+ protected void setupServerFromParameters(String hostname, int port, String name, int keepAlive) throws IOException, IDCreateException {
+ final String hostnamePort = hostname + ":" + port; //$NON-NLS-1$
+ synchronized (serverGroups) {
+ SSLServerSOContainerGroup serverGroup = (SSLServerSOContainerGroup) serverGroups.get(hostnamePort);
+ if (serverGroup == null) {
+ System.out.println("Putting server " + hostnamePort + " on the air..."); //$NON-NLS-1$ //$NON-NLS-2$
+ try {
+ serverGroup = new SSLServerSOContainerGroup(hostname, port);
+ final String url = SSLServerSOContainer.DEFAULT_PROTOCOL + "://" //$NON-NLS-1$
+ + hostnamePort + name;
+ // Create
+ final SSLServerSOContainer container = createServerContainer(url, serverGroup, name, keepAlive);
+ // Configure
+ configureServerContainer(container);
+ // Put on the air
+ serverGroup.putOnTheAir();
+ } catch (final IOException e) {
+ e.printStackTrace(System.err);
+ throw e;
+ } catch (IDCreateException e) {
+ e.printStackTrace(System.err);
+ throw e;
+ }
+ serverGroups.put(hostnamePort, serverGroup);
+ System.out.println("SSLGenericServerContainer " + hostnamePort + " on the air."); //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ System.out.println("SSLGenericServerContainer " + hostnamePort //$NON-NLS-1$
+ + " already on the air. No changes made."); //$NON-NLS-1$
+ }
+ }
+
+ }
+
+ /**
+ * This method may be overridden by subclasses in order to customize the configuration of the
+ * newly created server containers (before they are put on the air). For example, to set the appropriate
+ * connect policy.
+ *
+ * @param container the container to configure
+ */
+ protected void configureServerContainer(SSLServerSOContainer container) {
+ // Setup join policy
+ ((ISharedObjectContainerGroupManager) container).setConnectPolicy(new JoinListener());
+
+ }
+
+ protected void setupServerFromConfig(List connectors) throws IOException, IDCreateException {
+ for (final Iterator i = connectors.iterator(); i.hasNext();) {
+ final Connector connector = (Connector) i.next();
+ final String hostname = connector.getHostname();
+ final int port = connector.getPort();
+ final String hostnamePort = hostname + ":" + port; //$NON-NLS-1$
+ SSLServerSOContainerGroup serverGroup = null;
+ synchronized (serverGroups) {
+ serverGroup = (SSLServerSOContainerGroup) serverGroups.get(hostnamePort);
+ if (serverGroup == null) {
+ System.out.println("Putting server " + hostnamePort + " on the air..."); //$NON-NLS-1$ //$NON-NLS-2$
+ serverGroup = new SSLServerSOContainerGroup(hostname, port);
+ final List groups = connector.getGroups();
+ for (final Iterator g = groups.iterator(); g.hasNext();) {
+ final NamedGroup group = (NamedGroup) g.next();
+ // Create
+ final SSLServerSOContainer container = createServerContainer(group.getIDForGroup(), serverGroup, group.getName(), connector.getTimeout());
+ // Configure
+ configureServerContainer(container);
+ }
+ serverGroup.putOnTheAir();
+ serverGroups.put(hostnamePort, serverGroup);
+ System.out.println("GenericServerContainer " + hostnamePort //$NON-NLS-1$
+ + " on the air."); //$NON-NLS-1$
+ } else {
+ System.out.println("GenericServerContainer " + hostnamePort //$NON-NLS-1$
+ + " already on the air. No changes made."); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.equinox.app.IApplication#stop()
+ */
+ public void stop() {
+ synchronized (serverGroups) {
+ for (final Iterator i = serverGroups.keySet().iterator(); i.hasNext();) {
+ final SSLServerSOContainerGroup serverGroup = (SSLServerSOContainerGroup) serverGroups.get(i.next());
+ serverGroup.takeOffTheAir();
+ System.out.println("Taking " + serverGroup.getName() + ":" + serverGroup.getPort() + " off the air"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ final Iterator iter = serverGroup.elements();
+ for (; iter.hasNext();) {
+ final TCPServerSOContainer container = (TCPServerSOContainer) iter.next();
+ container.dispose();
+ }
+ }
+ }
+ serverGroups.clear();
+ synchronized (this) {
+ this.notify();
+ }
+ }
+
+ private String[] mungeArguments(String originalArgs[]) {
+ if (originalArgs == null)
+ return new String[0];
+ final List l = new ArrayList();
+ for (int i = 0; i < originalArgs.length; i++)
+ if (!originalArgs[i].equals("-pdelaunch")) //$NON-NLS-1$
+ l.add(originalArgs[i]);
+ return (String[]) l.toArray(new String[] {});
+ }
+
+ private static SSLServerSOContainer createServerContainer(String id, SSLServerSOContainerGroup group, String path, int keepAlive) throws IDCreateException {
+ System.out.println(" Creating container with id=" + id + " keepAlive=" + keepAlive); //$NON-NLS-1$ //$NON-NLS-2$
+ final ID newServerID = IDFactory.getDefault().createStringID(id);
+ final SOContainerConfig config = new SOContainerConfig(newServerID);
+ return new SSLServerSOContainer(config, group, path, keepAlive);
+ }
+
+ static class JoinListener implements IConnectHandlerPolicy {
+ public PermissionCollection checkConnect(Object addr, ID fromID, ID targetID, String targetGroup, Object joinData) throws Exception {
+ System.out.println("CLIENT CONNECT: fromAddress=" + addr + ";fromID=" + fromID + ";targetGroup=" + targetGroup); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return null;
+ }
+
+ public void refresh() {
+ // nothing to do
+ }
+
+ }
+
+}
diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/SSLGenericServerApplication.java b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/SSLGenericServerApplication.java
new file mode 100644
index 000000000..07fffc258
--- /dev/null
+++ b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/SSLGenericServerApplication.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+* Copyright (c) 2013 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.server.generic.app;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.equinox.app.IApplication;
+import org.eclipse.equinox.app.IApplicationContext;
+
+/**
+ * @since 6.0
+ */
+public class SSLGenericServerApplication extends AbstractSSLGenericServerApplication implements IApplication {
+
+ protected final Object appLock = new Object();
+ protected boolean done = false;
+
+ public Object start(IApplicationContext context) throws Exception {
+ String[] args = getArguments(context);
+ processArguments(args);
+
+ initialize();
+
+ if (configURL != null)
+ System.out.println("SSL Generic server started with config from " + configURL); //$NON-NLS-1$
+ else
+ System.out.println("SSL Generic server started with id=" + serverName); //$NON-NLS-1$
+
+ waitForDone();
+
+ return IApplication.EXIT_OK;
+ }
+
+ public void stop() {
+ shutdown();
+ synchronized (appLock) {
+ done = true;
+ appLock.notifyAll();
+ }
+ }
+
+ protected void waitForDone() {
+ // then just wait here
+ synchronized (appLock) {
+ while (!done) {
+ try {
+ appLock.wait();
+ } catch (InterruptedException e) {
+ // do nothing
+ }
+ }
+ }
+ }
+
+ protected String[] getArguments(IApplicationContext context) {
+ String[] originalArgs = (String[]) context.getArguments().get("application.args"); //$NON-NLS-1$
+ if (originalArgs == null)
+ return new String[0];
+ final List l = new ArrayList();
+ for (int i = 0; i < originalArgs.length; i++)
+ if (!originalArgs[i].equals("-pdelaunch")) //$NON-NLS-1$
+ l.add(originalArgs[i]);
+ return (String[]) l.toArray(new String[] {});
+ }
+
+}
diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/SSLGenericServerJavaApplication.java b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/SSLGenericServerJavaApplication.java
new file mode 100644
index 000000000..d2c96248a
--- /dev/null
+++ b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/SSLGenericServerJavaApplication.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+* Copyright (c) 2013 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.server.generic.app;
+
+/**
+ * @since 6.0
+ */
+public class SSLGenericServerJavaApplication extends AbstractSSLGenericServerApplication {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) throws Exception {
+ SSLGenericServerJavaApplication app = new SSLGenericServerJavaApplication();
+ app.processArguments(args);
+ app.initialize();
+ if (app.configURL != null)
+ System.out.println("SSL Generic server started with config from " + app.configURL); //$NON-NLS-1$
+ else
+ System.out.println("SSL Generic server started with id=" + app.serverName); //$NON-NLS-1$
+ System.out.println("Ctrl-c to exit"); //$NON-NLS-1$
+ }
+
+}
diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/sslserver.xml b/server-side/bundles/org.eclipse.ecf.server.generic/sslserver.xml
new file mode 100644
index 000000000..435352814
--- /dev/null
+++ b/server-side/bundles/org.eclipse.ecf.server.generic/sslserver.xml
@@ -0,0 +1,5 @@
+<server>
+ <connector protocol="ecfssl" hostname="localhost" port="4282" timeout="30000">
+ <group name="secureserver"/>
+ </connector>
+</server> \ No newline at end of file

Back to the top