Search in sources :

Example 1 with User

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

the class EditUsersDialog method onOk.

protected void onOk() {
    List<Group> grps = factory.getGroups();
    for (Group group : groupsToUpdate) {
        if (findGroup(group.getName(), grps) != null) {
            factory.updateGroup(group);
        } else {
            factory.createGroup(group);
        }
    }
    List<User> urs = factory.getUsers();
    for (User user : usersToUpdate) {
        if (findUser(user.getLogin(), urs) != null) {
            factory.updateUser(user);
        } else {
            factory.createUser(user);
        }
    }
    for (String group : groupsToDelete) {
        factory.deleteGroup(group);
    }
    for (String user : usersToDelete) {
        factory.deleteUser(user);
    }
    super.onOk();
}
Also used : Group(com.ramussoft.net.common.Group) User(com.ramussoft.net.common.User)

Example 2 with User

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

the class ServerIEngineImpl method transformStreamName.

private String transformStreamName(String oldPath) {
    if (oldPath.startsWith(USER)) {
        if (serverAccessRules == null) {
            return oldPath;
        }
        String end = oldPath.substring(USER.length() - 1);
        User user = serverAccessRules.getUser();
        if ("admin".equals(user.getLogin()))
            return oldPath;
        String login = user.getLogin();
        return USER + login + end;
    }
    return oldPath;
}
Also used : User(com.ramussoft.net.common.User)

Example 3 with User

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

the class UserFactoryImpl method getUser.

@Override
public User getUser(final String login) {
    return (User) template.execute(new JDBCCallback() {

        @Override
        public Object execute(Connection connection) throws SQLException {
            PreparedStatement selUser = connection.prepareStatement("SELECT * FROM USERS WHERE \"login\"=?");
            selUser.setString(1, login);
            ResultSet rs = selUser.executeQuery();
            PreparedStatement groupQualifiers = template.getConnection().prepareStatement("SELECT qualifier_id FROM group_qualifier_access WHERE group_name=? ORDER BY qualifier_id");
            if (rs.next()) {
                PreparedStatement groups = connection.prepareStatement("SELECT * FROM users_groups WHERE \"login\"=? ORDER BY group_name");
                User user = createUser(groups, rs, groupQualifiers);
                groups.close();
                rs.close();
                selUser.close();
                return user;
            }
            rs.close();
            groupQualifiers.close();
            selUser.close();
            return null;
        }
    });
}
Also used : User(com.ramussoft.net.common.User) JDBCCallback(com.ramussoft.jdbc.JDBCCallback) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement)

Example 4 with User

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

the class ClientServiceImpl method changePassword.

@Override
public void changePassword(String newPassword) {
    User me = me();
    if (me == null)
        return;
    me.setPassword(newPassword);
    userFactory.updateUser(me);
}
Also used : User(com.ramussoft.net.common.User)

Example 5 with User

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

the class ClientServiceImpl method login.

@Override
public Long login(String login, String password) {
    if (!Metadata.CORPORATE) {
        if (server.getConnectionsCount() >= 3)
            return -1l;
    } else {
        int cc = ServerConnection.getConnectionCount(EngineFactory.getPropeties());
        if (cc >= 0) {
            if (server.getConnectionsCount() >= cc)
                return -1l;
        }
    }
    User user = userFactory.getUser(login);
    if (user == null)
        return -1l;
    if (!user.getPassword().equals(password))
        user = null;
    if (user == null)
        return -1l;
    this.user = user;
    for (Group group : user.getGroups()) {
        if (group.getName().equals("admin")) {
            userFactoryClient.setAdmin(true);
            break;
        }
    }
    setLogin(login);
    return 1l;
}
Also used : Group(com.ramussoft.net.common.Group) User(com.ramussoft.net.common.User)

Aggregations

User (com.ramussoft.net.common.User)17 Group (com.ramussoft.net.common.Group)7 ResultSet (java.sql.ResultSet)3 JDBCCallback (com.ramussoft.jdbc.JDBCCallback)2 ActionEvent (java.awt.event.ActionEvent)2 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 AbstractAction (javax.swing.AbstractAction)2 AccessRules (com.ramussoft.common.AccessRules)1 Engine (com.ramussoft.common.Engine)1 PluginFactory (com.ramussoft.common.PluginFactory)1 PluginProvider (com.ramussoft.common.PluginProvider)1 Qualifier (com.ramussoft.common.Qualifier)1 SimpleAttributePluginSuit (com.ramussoft.core.attribute.simple.SimpleAttributePluginSuit)1 IntegrityAccessorSuit (com.ramussoft.core.impl.IntegrityAccessorSuit)1 PersistentFactory (com.ramussoft.core.persistent.PersistentFactory)1 AbstractGUIPluginFactory (com.ramussoft.gui.common.AbstractGUIPluginFactory)1 ActionDescriptor (com.ramussoft.gui.common.ActionDescriptor)1