Search in sources :

Example 1 with UserFactory

use of com.ramussoft.net.common.UserFactory in project ramus by Vitaliy-Yakovchuk.

the class LightClient method initAdditionalGuiPlugins.

@Override
protected void initAdditionalGuiPlugins(List<GUIPlugin> list) {
    super.initAdditionalGuiPlugins(list);
    list.add(new ClientPlugin(userProvider, true));
    if (isAdmin(getMe())) {
        UserFactory userFactory;
        try {
            userFactory = (UserFactory) proxyFactory.create(UserFactory.class, URL_USER_FACTORY);
        } catch (MalformedURLException e1) {
            e1.printStackTrace();
            throw new RuntimeException(e1);
        }
        AdminPanelPlugin adminPanelPlugin = new AdminPanelPlugin(userFactory, e);
        list.add(adminPanelPlugin);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) UserFactory(com.ramussoft.net.common.UserFactory)

Example 2 with UserFactory

use of com.ramussoft.net.common.UserFactory in project ramus by Vitaliy-Yakovchuk.

the class InternetServer method run.

private void run(String[] args) throws IOException {
    new File(tmpPath).mkdirs();
    engineFactory = new EngineFactory() {
    };
    final ServerSocket ss = new ServerSocket();
    ss.bind(new InetSocketAddress("0.0.0.0", Metadata.INTERNET_PORT));
    userFactory = new UserFactoryImpl(engineFactory.getTemplate());
    serverAccessRules = new ServerAccessRules(engineFactory.getEngine(), userFactory) {

        @Override
        protected String getLogin() {
            return logins.get(Thread.currentThread());
        }
    };
    Thread acceptionThread = new Thread(new Runnable() {

        @Override
        public void run() {
            System.out.println("Ramus Interner Server ready");
            while (true) {
                try {
                    final Thread thread;
                    final Socket socket = ss.accept();
                    CheckableUserFactory userFactoryClient = new CheckableUserFactory(userFactory);
                    IntegrityAccessorSuit suit = new IntegrityAccessorSuit();
                    suit.addAccessRules(serverAccessRules);
                    suit.addAccessRules(((IEngineImpl) getEngine().getDeligate()).getAccessor());
                    final ClientServiceImpl service = new ClientServiceImpl(InternetServer.this, userFactory, userFactoryClient);
                    SuperInvoker invoker = new SuperInvoker(new Object[] { service, suit, userFactoryClient, service }, new Class[] { ClientService.class, AccessRules.class, UserFactory.class, UserProvider.class });
                    final TcpServerConnection connection = new TcpServerConnection(socket, new String[] { ClientService.class.getName(), AccessRules.class.getName(), UserFactory.class.getName(), UserProvider.class.getName() }, invoker.createProxy()) {

                        public void close() throws IOException {
                            synchronized (servicesLock) {
                                services.remove(service);
                            }
                            service.close();
                            super.close();
                        }
                    };
                    synchronized (servicesLock) {
                        services.add(service);
                    }
                    thread = new Thread(new Runnable() {

                        @Override
                        public void run() {
                            connection.run();
                        }
                    }, "server-client");
                    service.setConnection(connection);
                    thread.start();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }, "inet-server-main");
    acceptionThread.start();
}
Also used : EngineFactory(com.ramussoft.server.EngineFactory) IntegrityAccessorSuit(com.ramussoft.core.impl.IntegrityAccessorSuit) ClientService(com.ramussoft.net.common.internet.ClientService) InetSocketAddress(java.net.InetSocketAddress) UserFactory(com.ramussoft.net.common.UserFactory) CheckableUserFactory(com.ramussoft.server.CheckableUserFactory) ServerSocket(java.net.ServerSocket) SuperInvoker(com.ramussoft.net.common.SuperInvoker) IOException(java.io.IOException) TcpServerConnection(com.ramussoft.server.TcpServerConnection) UserFactoryImpl(com.ramussoft.server.UserFactoryImpl) IEngineImpl(com.ramussoft.core.impl.IEngineImpl) FileIEngineImpl(com.ramussoft.core.impl.FileIEngineImpl) UserProvider(com.ramussoft.net.common.UserProvider) ServerAccessRules(com.ramussoft.server.ServerAccessRules) ServerAccessRules(com.ramussoft.server.ServerAccessRules) AccessRules(com.ramussoft.common.AccessRules) CheckableUserFactory(com.ramussoft.server.CheckableUserFactory) RedoObject(com.ramussoft.net.common.internet.RedoObject) UndoObject(com.ramussoft.net.common.internet.UndoObject) File(java.io.File) Socket(java.net.Socket) ServerSocket(java.net.ServerSocket)

Example 3 with UserFactory

use of com.ramussoft.net.common.UserFactory in project ramus by Vitaliy-Yakovchuk.

the class InternetClient method initAdditionalGuiPlugins.

@Override
protected void initAdditionalGuiPlugins(List<GUIPlugin> plugins) {
    super.initAdditionalGuiPlugins(plugins);
    plugins.add(new UndoRedoPlugin(e));
    plugins.add(new ClientPlugin(userProvider, true));
    try {
        if ((Boolean) connection.invoke("isAdmin", new Object[] {})) {
            UserFactory userFactory;
            userFactory = (UserFactory) createDeligate(UserFactory.class);
            AdminPanelPlugin adminPanelPlugin = new AdminPanelPlugin(userFactory, e);
            plugins.add(adminPanelPlugin);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : UserFactory(com.ramussoft.net.common.UserFactory) RedoObject(com.ramussoft.net.common.internet.RedoObject) UndoObject(com.ramussoft.net.common.internet.UndoObject) ZipException(java.util.zip.ZipException) FileNotFoundException(java.io.FileNotFoundException) InvalidPropertiesFormatException(java.util.InvalidPropertiesFormatException) SQLException(java.sql.SQLException) IOException(java.io.IOException) UndoRedoPlugin(com.ramussoft.gui.common.UndoRedoPlugin)

Example 4 with UserFactory

use of com.ramussoft.net.common.UserFactory in project ramus by Vitaliy-Yakovchuk.

the class TcpLightClient method initAdditionalGuiPlugins.

@Override
protected void initAdditionalGuiPlugins(List<GUIPlugin> list) {
    super.initAdditionalGuiPlugins(list);
    list.add(new ClientPlugin(userProvider, true));
    list.add(new LogPlugin());
    try {
        if ((Boolean) connection.invoke("canUndoRedo", new Object[] {}))
            list.add(new UndoRedoPlugin(e));
        if ((Boolean) connection.invoke("isAdmin", new Object[] {})) {
            UserFactory userFactory;
            userFactory = (UserFactory) createDeligate(UserFactory.class);
            AdminPanelPlugin adminPanelPlugin = new AdminPanelPlugin(userFactory, e);
            list.add(adminPanelPlugin);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : LogPlugin(com.ramussoft.client.log.LogPlugin) UserFactory(com.ramussoft.net.common.UserFactory) IOException(java.io.IOException) UndoRedoPlugin(com.ramussoft.gui.common.UndoRedoPlugin)

Aggregations

UserFactory (com.ramussoft.net.common.UserFactory)4 IOException (java.io.IOException)3 UndoRedoPlugin (com.ramussoft.gui.common.UndoRedoPlugin)2 RedoObject (com.ramussoft.net.common.internet.RedoObject)2 UndoObject (com.ramussoft.net.common.internet.UndoObject)2 LogPlugin (com.ramussoft.client.log.LogPlugin)1 AccessRules (com.ramussoft.common.AccessRules)1 FileIEngineImpl (com.ramussoft.core.impl.FileIEngineImpl)1 IEngineImpl (com.ramussoft.core.impl.IEngineImpl)1 IntegrityAccessorSuit (com.ramussoft.core.impl.IntegrityAccessorSuit)1 SuperInvoker (com.ramussoft.net.common.SuperInvoker)1 UserProvider (com.ramussoft.net.common.UserProvider)1 ClientService (com.ramussoft.net.common.internet.ClientService)1 CheckableUserFactory (com.ramussoft.server.CheckableUserFactory)1 EngineFactory (com.ramussoft.server.EngineFactory)1 ServerAccessRules (com.ramussoft.server.ServerAccessRules)1 TcpServerConnection (com.ramussoft.server.TcpServerConnection)1 UserFactoryImpl (com.ramussoft.server.UserFactoryImpl)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1