Search in sources :

Example 1 with Group

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

the class EditUsersDialog method updateGroup.

private void updateGroup(Group group) {
    Group g = findGroup(group.getName(), groupsToUpdate);
    if (g != null)
        groupsToUpdate.remove(g);
    groupsToUpdate.add(group);
}
Also used : Group(com.ramussoft.net.common.Group)

Example 2 with Group

use of com.ramussoft.net.common.Group 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 3 with Group

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

the class DaoSupportImpl method loadUserByUsername.

@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
    com.ramussoft.net.common.User user = getUserFactory().getUser(username);
    if (user == null) {
        throw new UsernameNotFoundException(MessageFormat.format("User {0} not found", username));
    }
    List<Group> list = user.getGroups();
    GrantedAuthority[] arrayAuths = new GrantedAuthority[list.size() + 1];
    for (int i = 0; i < list.size(); i++) {
        arrayAuths[i] = new GrantedAuthorityImpl("ROLE_" + list.get(i).getName().toUpperCase());
    }
    arrayAuths[list.size()] = new GrantedAuthorityImpl("ROLE_USER");
    return new User(user.getLogin(), user.getPassword(), true, true, true, true, arrayAuths);
}
Also used : UsernameNotFoundException(org.acegisecurity.userdetails.UsernameNotFoundException) Group(com.ramussoft.net.common.Group) User(org.acegisecurity.userdetails.User) GrantedAuthorityImpl(org.acegisecurity.GrantedAuthorityImpl) GrantedAuthority(org.acegisecurity.GrantedAuthority)

Example 4 with Group

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

the class UserFactoryImpl method getGroup.

@Override
public Group getGroup(String groupName) {
    Group group = new Group();
    group.setName(groupName);
    return group;
}
Also used : Group(com.ramussoft.net.common.Group)

Example 5 with Group

use of com.ramussoft.net.common.Group 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

Group (com.ramussoft.net.common.Group)11 User (com.ramussoft.net.common.User)7 AccessRules (com.ramussoft.common.AccessRules)1 Qualifier (com.ramussoft.common.Qualifier)1 UserProvider (com.ramussoft.net.common.UserProvider)1 ActionEvent (java.awt.event.ActionEvent)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 PrintStream (java.io.PrintStream)1 ResultSet (java.sql.ResultSet)1 Calendar (java.util.Calendar)1 ResourceBundle (java.util.ResourceBundle)1 AbstractAction (javax.swing.AbstractAction)1 ImageIcon (javax.swing.ImageIcon)1 AbstractTableModel (javax.swing.table.AbstractTableModel)1 GrantedAuthority (org.acegisecurity.GrantedAuthority)1