use of org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIEEUser in project pentaho-kettle by pentaho.
the class UIEESecurityTest method testUpdateUser.
@Test
public void testUpdateUser() throws Exception {
try {
UIEERepositoryUser userToAdd = new UIEERepositoryUser(new EEUserInfo());
userToAdd.setName("newuser");
userToAdd.setPassword("newpassword");
userToAdd.setDescription("new description");
Set<IUIRole> rolesToAssign = new HashSet<IUIRole>();
rolesToAssign.add(new UIRepositoryRole(ctoRole));
rolesToAssign.add(new UIRepositoryRole(isRole));
rolesToAssign.add(new UIRepositoryRole(adminRole));
rolesToAssign.add(new UIRepositoryRole(authenticatedRole));
userToAdd.setRoles(rolesToAssign);
security.addUser(userToAdd);
IUIUser selectedUser = security.getSelectedUser();
selectedUser.setPassword("newpassword123");
selectedUser.setDescription("new description 123");
((IUIEEUser) selectedUser).addRole(new UIRepositoryRole(ctoRole));
((IUIEEUser) selectedUser).addRole(new UIRepositoryRole(isRole));
((IUIEEUser) selectedUser).removeRole(new UIRepositoryRole(adminRole));
((IUIEEUser) selectedUser).removeRole(new UIRepositoryRole(authenticatedRole));
security.updateUser(selectedUser, rolesToAssign);
// $NON-NLS-1$
assertEquals(selectedUser.getPassword(), "newpassword123");
// $NON-NLS-1$
assertEquals(selectedUser.getDescription(), "new description 123");
assertEquals(security.getSelectedUser(), selectedUser);
assertEquals(security.getUserList().size(), 5);
} catch (Exception e) {
Assert.fail();
}
}
use of org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIEEUser 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.pur.repositoryexplorer.IUIEEUser in project pentaho-kettle by pentaho.
the class UIEESecurity method removeUser.
@Override
public void removeUser(IUIUser userToRemove) {
int index = getIndexOfUser(userToRemove);
userList.remove(userToRemove);
// $NON-NLS-1$
this.firePropertyChange("userList", null, userList);
// We need to make sure this recently removed user is removed to all roles as well
if (userToRemove instanceof IUIEEUser) {
for (IUIRole role : ((IUIEEUser) userToRemove).getRoles()) {
unassignUserFromRole(role, userToRemove);
}
}
if (index - 1 >= 0) {
setSelectedUser(getUserAtIndex(index - 1));
}
}
use of org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIEEUser in project pentaho-kettle by pentaho.
the class UIEESecurity method addUser.
@Override
public void addUser(IUIUser userToAdd) {
userList.add(userToAdd);
Collections.sort(userList);
// $NON-NLS-1$
this.firePropertyChange("userList", null, userList);
// We need to make sure this recently removed user is removed from all roles as well
if (userToAdd instanceof IUIEEUser) {
for (IUIRole role : ((IUIEEUser) userToAdd).getRoles()) {
assignUserToRole(role, userToAdd);
}
}
setSelectedUser(userToAdd);
}
use of org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIEEUser in project pentaho-kettle by pentaho.
the class UIEESecurityUser method setUser.
public void setUser(IUIUser user, List<IUIRole> roles) throws Exception {
super.setUser(user);
setAvailableRoles(roles);
if (user instanceof IUIEEUser) {
for (IUIRole role : ((IUIEEUser) user).getRoles()) {
removeFromAvailableRoles(role.getName());
addToAssignedRoles(UIEEObjectRegistery.getInstance().constructUIRepositoryRole(role.getRole()));
}
}
}
Aggregations