use of org.pentaho.di.ui.repository.repositoryexplorer.model.IUIUser in project pentaho-kettle by pentaho.
the class UIEESecurity method updateUser.
public void updateUser(IUIUser userToUpdate, Set<IUIRole> previousRoleList) {
IUIUser user = getUser(userToUpdate.getName());
user.setDescription(userToUpdate.getDescription());
if (userToUpdate instanceof IUIEEUser) {
((IUIEEUser) user).setRoles(((IUIEEUser) userToUpdate).getRoles());
}
// $NON-NLS-1$
this.firePropertyChange("userList", null, userList);
/*
* Now update this current user to all the roles. So if any roles were added to this user then add the user to the
* roles as well. Similarly if some roles were remove from this user, remove the user from those roles.
*/
updateUserInRoles(userToUpdate, previousRoleList, ((IUIEEUser) userToUpdate).getRoles());
setSelectedUser(user);
}
use of org.pentaho.di.ui.repository.repositoryexplorer.model.IUIUser in project pentaho-kettle by pentaho.
the class UIEESecurity method removeUsersFromSelectedRole.
public void removeUsersFromSelectedRole(Collection<Object> users) {
for (Object o : users) {
IUIUser user = (IUIUser) o;
removeUserFromSelectedRole(user.getName());
}
// $NON-NLS-1$
this.firePropertyChange("selectedRole", null, selectedRole);
}
use of org.pentaho.di.ui.repository.repositoryexplorer.model.IUIUser in project pentaho-kettle by pentaho.
the class UIEESecurity method removeRole.
public void removeRole(IUIRole roleToRemove) {
int index = getIndexOfRole(roleToRemove);
roleList.remove(roleToRemove);
// $NON-NLS-1$
this.firePropertyChange("roleList", null, roleList);
// We need to make sure this new role is added to all users as well
for (IUIUser userInfo : roleToRemove.getUsers()) {
unassignRoleFromUser(userInfo, roleToRemove);
}
if (index - 1 >= 0) {
setSelectedRole(getRoleAtIndex(index - 1));
}
}
use of org.pentaho.di.ui.repository.repositoryexplorer.model.IUIUser in project pentaho-kettle by pentaho.
the class UIEESecurityTest method testUpdateRole.
@Test
public void testUpdateRole() throws Exception {
try {
IUIRole roleToAdd = new UIRepositoryRole(new EERoleInfo());
roleToAdd.setName("newrole");
roleToAdd.setDescription("new description");
Set<IUIUser> usersToAssign = new HashSet<IUIUser>();
usersToAssign.add(new UIRepositoryUser(suzyUser));
usersToAssign.add(new UIRepositoryUser(tiffanyUser));
usersToAssign.add(new UIRepositoryUser(joeUser));
roleToAdd.setUsers(usersToAssign);
security.addRole(roleToAdd);
security.setSelectedRole(findRole("newrole"));
IUIRole selectedRole = security.getSelectedRole();
selectedRole.setDescription("new description 123");
selectedRole.addUser(new UIRepositoryUser(patUser));
selectedRole.removeUser(new UIRepositoryUser(suzyUser));
selectedRole.removeUser(new UIRepositoryUser(tiffanyUser));
security.updateRole(selectedRole, usersToAssign);
// $NON-NLS-1$
assertEquals(selectedRole.getDescription(), "new description 123");
assertEquals(security.getSelectedRole(), selectedRole);
assertEquals(security.getRoleList().size(), 9);
} catch (Exception e) {
Assert.fail();
}
}
use of org.pentaho.di.ui.repository.repositoryexplorer.model.IUIUser in project pentaho-kettle by pentaho.
the class UIEESecurityTest method init.
@Before
public void init() {
roles.add(adminRole);
roles.add(anonymousRole);
roles.add(authenticatedRole);
roles.add(ceoRole);
roles.add(ctoRole);
roles.add(devRole);
roles.add(devmgrRole);
roles.add(isRole);
joeUser = new EEUserInfo("joe", "password", "joe", "joe", true);
patUser = new EEUserInfo("pat", "password", "pat", "pat", true);
suzyUser = new EEUserInfo("suzy", "password", "suzy", "suzy", true);
tiffanyUser = new EEUserInfo("tiffany", "password", "tiffany", "tiffany", true);
joeUser.addRole(roles.get(0));
joeUser.addRole(roles.get(2));
joeUser.addRole(roles.get(3));
suzyUser.addRole(roles.get(2));
suzyUser.addRole(roles.get(4));
suzyUser.addRole(roles.get(7));
patUser.addRole(roles.get(2));
patUser.addRole(roles.get(5));
tiffanyUser.addRole(roles.get(2));
tiffanyUser.addRole(roles.get(5));
tiffanyUser.addRole(roles.get(6));
adminRole.addUser(joeUser);
adminRole.addUser(patUser);
anonymousRole.addUser(tiffanyUser);
authenticatedRole.addUser(joeUser);
authenticatedRole.addUser(patUser);
authenticatedRole.addUser(suzyUser);
authenticatedRole.addUser(tiffanyUser);
ceoRole.addUser(joeUser);
ctoRole.addUser(patUser);
devmgrRole.addUser(joeUser);
devmgrRole.addUser(patUser);
isRole.addUser(joeUser);
isRole.addUser(suzyUser);
users.add(joeUser);
users.add(patUser);
users.add(suzyUser);
users.add(tiffanyUser);
rroles = new ArrayList<IUIRole>();
for (IRole EERoleInfo : roles) {
IUIRole role = new UIRepositoryRole(EERoleInfo);
rroles.add(role);
}
rusers = new ArrayList<IUIUser>();
for (IUser eEUserInfo : users) {
rusers.add(new UIRepositoryUser(eEUserInfo));
}
security.setUserList(rusers);
security.setRoleList(rroles);
}
Aggregations