Search in sources :

Example 1 with IConnectHandlerPolicy

use of org.eclipse.ecf.core.security.IConnectHandlerPolicy in project ecf by eclipse.

the class Activator method createAndConfigureHostContainer.

private void createAndConfigureHostContainer(BundleContext context) throws Exception {
    // Get IContainerManager singleton
    ServiceTracker<IContainerManager, IContainerManager> containerManagerTracker = new ServiceTracker<IContainerManager, IContainerManager>(context, IContainerManager.class.getName(), null);
    containerManagerTracker.open();
    IContainerManager containerManager = containerManagerTracker.getService();
    if (containerManager == null)
        throw new NullPointerException("Cannot get IContainerManager service");
    containerManagerTracker.close();
    // Now create a hostContainer instance
    hostContainer = containerManager.getContainerFactory().createContainer("ecf.generic.server");
    // Get the ISharedObjectContainerGroupManager adapter interface
    ISharedObjectContainerGroupManager hostManager = (ISharedObjectContainerGroupManager) hostContainer.getAdapter(ISharedObjectContainerGroupManager.class);
    // Set connect policy
    hostManager.setConnectPolicy(new IConnectHandlerPolicy() {

        public void refresh() {
        }

        public PermissionCollection checkConnect(Object address, ID fromID, ID targetID, String targetGroup, Object connectData) throws Exception {
            // What we will do when we receive a check connect call is to call
            // verifyClientConnect
            verifyClientConnect(fromID, connectData);
            return null;
        }
    });
}
Also used : PermissionCollection(java.security.PermissionCollection) ISharedObjectContainerGroupManager(org.eclipse.ecf.core.sharedobject.ISharedObjectContainerGroupManager) IConnectHandlerPolicy(org.eclipse.ecf.core.security.IConnectHandlerPolicy) ServiceTracker(org.osgi.util.tracker.ServiceTracker) IContainerManager(org.eclipse.ecf.core.IContainerManager) ID(org.eclipse.ecf.core.identity.ID)

Example 2 with IConnectHandlerPolicy

use of org.eclipse.ecf.core.security.IConnectHandlerPolicy in project ecf by eclipse.

the class AbstractGenericServer method createAndInitializeServer.

protected void createAndInitializeServer(String path, int keepAlive) throws IDCreateException {
    if (// $NON-NLS-1$
    path == null || path.equals(""))
        // $NON-NLS-1$
        throw new NullPointerException("Cannot create ID with null or empty path");
    GenericServerContainer s = new GenericServerContainer(this, createServerConfig(path), serverGroup, path, keepAlive);
    IContainerManager containerManager = Activator.getDefault().getContainerManager();
    if (containerManager != null) {
        // $NON-NLS-1$
        ContainerTypeDescription ctd = containerManager.getContainerFactory().getDescriptionByName("ecf.generic.server");
        containerManager.addContainer(s, ctd);
    }
    IConnectHandlerPolicy policy = createConnectHandlerPolicy(s, path);
    if (policy != null)
        s.setConnectPolicy(policy);
}
Also used : IConnectHandlerPolicy(org.eclipse.ecf.core.security.IConnectHandlerPolicy) ContainerTypeDescription(org.eclipse.ecf.core.ContainerTypeDescription) IContainerManager(org.eclipse.ecf.core.IContainerManager)

Example 3 with IConnectHandlerPolicy

use of org.eclipse.ecf.core.security.IConnectHandlerPolicy in project ecf by eclipse.

the class SSLAbstractGenericServer method createAndInitializeServer.

protected void createAndInitializeServer(String path, int keepAlive) throws IDCreateException {
    if (// $NON-NLS-1$
    path == null || path.equals(""))
        // $NON-NLS-1$
        throw new NullPointerException("Cannot create ID with null or empty path");
    SSLGenericServerContainer s = new SSLGenericServerContainer(this, createServerConfig(path), serverGroup, path, keepAlive);
    IContainerManager containerManager = Activator.getDefault().getContainerManager();
    if (containerManager != null) {
        // $NON-NLS-1$
        ContainerTypeDescription ctd = containerManager.getContainerFactory().getDescriptionByName("ecf.generic.server");
        containerManager.addContainer(s, ctd);
    }
    IConnectHandlerPolicy policy = createConnectHandlerPolicy(s, path);
    if (policy != null)
        s.setConnectPolicy(policy);
}
Also used : IConnectHandlerPolicy(org.eclipse.ecf.core.security.IConnectHandlerPolicy) ContainerTypeDescription(org.eclipse.ecf.core.ContainerTypeDescription) IContainerManager(org.eclipse.ecf.core.IContainerManager)

Example 4 with IConnectHandlerPolicy

use of org.eclipse.ecf.core.security.IConnectHandlerPolicy in project ecf by eclipse.

the class RssServerSOContainer method main.

public static void main(String[] args) throws Exception {
    RssServerSOContainerGroup[] serverGroups = null;
    final List servers = new ArrayList();
    int port = DEFAULT_PORT;
    if (args.length > 0) {
        if (args[0].equals("-p")) {
            port = Integer.parseInt(args[1]);
        }
    }
    // Get server identity
    final String serverName = "//" + InetAddress.getLocalHost().getHostName() + ":" + port;
    serverGroups = new RssServerSOContainerGroup[1];
    // Setup server group
    serverGroups[0] = new RssServerSOContainerGroup(port);
    // Create identity for server
    final ID id = IDFactory.getDefault().createStringID(serverName);
    // Create server config object with identity and default timeout
    final SOContainerConfig config = new SOContainerConfig(id);
    // Make server instance
    System.out.println("Creating ECF server container...");
    final RssServerSOContainer server = new RssServerSOContainer(config, serverGroups[0], DEFAULT_KEEPALIVE);
    // Setup join policy
    ((ISharedObjectContainerGroupManager) server).setConnectPolicy(new IConnectHandlerPolicy() {

        public PermissionCollection checkConnect(Object address, ID fromID, ID targetID, String targetGroup, Object connectData) throws Exception {
            System.out.println("JOIN Addr=" + address + ";From=" + fromID + ";Group=" + targetGroup + ";Data=" + connectData);
            return null;
        }

        public void refresh() {
            System.out.println("joinPolicy.refresh()");
        }
    });
    // Setup add shared object policy
    final ISharedObjectManager manager = server.getSharedObjectManager();
    manager.setRemoteAddPolicy(new ISharedObjectPolicy() {

        public PermissionCollection checkAddSharedObject(ID fromID, ID toID, ID localID, ReplicaSharedObjectDescription newObjectDescription) throws SecurityException {
            System.out.println("ADDSHAREDOBJECT From=" + fromID + ";To=" + toID + ";SharedObjectDesc=" + newObjectDescription);
            return null;
        }

        public void refresh() {
            System.out.println("sharedObjectPolicy.refresh()");
        }
    });
    serverGroups[0].putOnTheAir();
    servers.add(server);
    System.out.println("success!");
    System.out.println("Waiting for JOIN requests at '" + id.getName() + "'...");
    System.out.println("<Ctrl>+C to stop server");
}
Also used : PermissionCollection(java.security.PermissionCollection) IConnectHandlerPolicy(org.eclipse.ecf.core.security.IConnectHandlerPolicy) ArrayList(java.util.ArrayList) ISharedObjectManager(org.eclipse.ecf.core.sharedobject.ISharedObjectManager) ReplicaSharedObjectDescription(org.eclipse.ecf.core.sharedobject.ReplicaSharedObjectDescription) SOContainerConfig(org.eclipse.ecf.provider.generic.SOContainerConfig) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) ISharedObjectPolicy(org.eclipse.ecf.core.sharedobject.security.ISharedObjectPolicy) ISharedObjectContainerGroupManager(org.eclipse.ecf.core.sharedobject.ISharedObjectContainerGroupManager) ArrayList(java.util.ArrayList) List(java.util.List) ID(org.eclipse.ecf.core.identity.ID)

Aggregations

IConnectHandlerPolicy (org.eclipse.ecf.core.security.IConnectHandlerPolicy)4 IContainerManager (org.eclipse.ecf.core.IContainerManager)3 PermissionCollection (java.security.PermissionCollection)2 ContainerTypeDescription (org.eclipse.ecf.core.ContainerTypeDescription)2 ID (org.eclipse.ecf.core.identity.ID)2 ISharedObjectContainerGroupManager (org.eclipse.ecf.core.sharedobject.ISharedObjectContainerGroupManager)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ISharedObjectManager (org.eclipse.ecf.core.sharedobject.ISharedObjectManager)1 ReplicaSharedObjectDescription (org.eclipse.ecf.core.sharedobject.ReplicaSharedObjectDescription)1 ISharedObjectPolicy (org.eclipse.ecf.core.sharedobject.security.ISharedObjectPolicy)1 SOContainerConfig (org.eclipse.ecf.provider.generic.SOContainerConfig)1 ServiceTracker (org.osgi.util.tracker.ServiceTracker)1