use of com.ramussoft.net.common.User in project ramus by Vitaliy-Yakovchuk.
the class EditUsersDialog method createActions.
private void createActions() {
editUser = new AbstractAction() {
{
putValue(SHORT_DESCRIPTION, plugin.getString("Action.EditUser"));
putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/com/ramussoft/client/edit_user.png")));
}
/**
*/
private static final long serialVersionUID = 3903478872742330272L;
public void actionPerformed(ActionEvent e) {
User user = getActiveUser();
if (user == null)
return;
EditUserDialog dialog = new EditUserDialog(EditUsersDialog.this, user, plugin);
dialog.setVisible(true);
updateUser(user);
userModel.fireTableDataChanged();
}
};
createUser = new AbstractAction() {
{
putValue(SHORT_DESCRIPTION, plugin.getString("Action.CreateUser"));
putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/com/ramussoft/client/add_user.png")));
}
/**
*/
private static final long serialVersionUID = -1876218590535351065L;
public void actionPerformed(ActionEvent e) {
EditUserDialog dialog = new EditUserDialog(EditUsersDialog.this, null, plugin);
dialog.setVisible(true);
User user = dialog.getUser();
if (user != null) {
User u = findUser(user.getLogin());
if (u != null) {
JOptionPane.showMessageDialog(EditUsersDialog.this, MessageFormat.format(plugin.getString("User.Exists"), u.getLogin()));
return;
}
usersToUpdate.add(user);
Group group = findGroup(user.getLogin());
if (group == null) {
group = new Group(user.getLogin());
groups.add(group);
groupsToUpdate.add(group);
user.getGroups().add(group);
groupModel.fireTableDataChanged();
}
users.add(user);
userModel.fireTableDataChanged();
u = findUser(user.getLogin());
if (u != null) {
usersToDelete.remove(u);
}
}
}
};
createGroup = new AbstractAction() {
/**
*/
private static final long serialVersionUID = 7889274557650997117L;
{
putValue(SHORT_DESCRIPTION, plugin.getString("Action.CreateGroup"));
putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/com/ramussoft/client/add_group.png")));
}
public void actionPerformed(ActionEvent e) {
String string = JOptionPane.showInputDialog(plugin.getString("Action.CreateGroup"));
if (string != null) {
if (findGroup(string) != null) {
JOptionPane.showMessageDialog(EditUsersDialog.this, MessageFormat.format(plugin.getString("Group.Exists"), string));
return;
}
Group g = findGroup(string);
if (g != null)
groupsToDelete.remove(g);
Group group = new Group(string);
groups.add(group);
groupsToUpdate.add(group);
groupModel.fireTableDataChanged();
}
}
};
deleteGroup = new AbstractAction() {
/**
*/
private static final long serialVersionUID = 7889274557650997117L;
{
putValue(SHORT_DESCRIPTION, plugin.getString("Action.DeleteGroup"));
putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/com/ramussoft/client/delete_group.png")));
}
public void actionPerformed(ActionEvent e) {
Group group = getActiveGroup();
if (group != null) {
if ((groupsToDelete.indexOf(group.getName())) < 0)
groupsToDelete.add(group.getName());
groups.remove(group);
groupModel.fireTableDataChanged();
groupsToUpdate.remove(group);
}
}
};
deleteUser = new AbstractAction() {
/**
*/
private static final long serialVersionUID = 7889274557650997117L;
{
putValue(SHORT_DESCRIPTION, plugin.getString("Action.DeleteUser"));
putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/com/ramussoft/client/delete_user.png")));
}
public void actionPerformed(ActionEvent e) {
User user = getActiveUser();
if (user != null) {
if ((usersToDelete.indexOf(user.getLogin())) < 0)
usersToDelete.add(user.getLogin());
users.remove(user);
usersToUpdate.remove(user);
userModel.fireTableDataChanged();
}
}
};
}
use of com.ramussoft.net.common.User in project ramus by Vitaliy-Yakovchuk.
the class RamusService 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;
setLogin(login);
for (Group group : user.getGroups()) {
if (group.getName().equals("admin")) {
userFactoryClient.setAdmin(true);
break;
}
}
return 1l;
}
use of com.ramussoft.net.common.User in project ramus by Vitaliy-Yakovchuk.
the class EngineConnection method getAccessRules.
public AccessRules getAccessRules(final User finalUser) {
if (finalUser == null)
return rules;
IntegrityAccessorSuit suit = new IntegrityAccessorSuit();
suit.addAccessRules(rules);
suit.addAccessRules(new ServerAccessRules(engine, userFactory) {
@Override
public User getUser() {
return finalUser;
}
});
return suit;
}
use of com.ramussoft.net.common.User in project ramus by Vitaliy-Yakovchuk.
the class ServerAccessRules method getUser.
public User getUser() {
synchronized (lock) {
String login = getLogin();
User user = users.get(login);
if (user != null)
return user;
user = userFactory.getUser(login);
if (user != null)
users.put(login, user);
return user;
}
}
use of com.ramussoft.net.common.User in project ramus by Vitaliy-Yakovchuk.
the class ServerAccessRules method isHasAccess.
private boolean isHasAccess(long qualifierId) {
boolean admin = isAdmin();
if (admin)
return true;
if (qualifierId == -1)
return false;
User user = getUser();
for (Group group : user.getGroups()) if (group.getName().equals("admin"))
return true;
else {
for (Long long1 : group.getQualifierIds()) if (long1.longValue() == qualifierId)
return true;
}
Qualifier qualifier = engine.getQualifier(qualifierId);
if (qualifier == null)
return admin;
if (qualifier.isSystem()) {
if (qualifier.getName().equals(StandardAttributesPlugin.QUALIFIERS_QUALIFIER))
return admin;
return true;
}
return false;
}
Aggregations