use of org.eclipse.ecf.core.sharedobject.security.ISharedObjectPolicy 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");
}
Aggregations