use of org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole 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.IUIRole in project pentaho-kettle by pentaho.
the class UIEESecurity method updateRole.
public void updateRole(IUIRole roleToUpdate, Set<IUIUser> previousUserList) {
IUIRole role = getRole(roleToUpdate.getName());
role.setDescription(roleToUpdate.getDescription());
role.setUsers(roleToUpdate.getUsers());
// $NON-NLS-1$
this.firePropertyChange("roleList", null, roleList);
/*
* Now update this current role to all the users. So if any users were added to this role then add the role to the
* users as well. Similarly if some users were remove from this role, remove the role from those users.
*/
updateRoleInUsers(roleToUpdate, previousUserList, roleToUpdate.getUsers());
setSelectedRole(role);
}
use of org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole 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()));
}
}
}
use of org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole in project pentaho-kettle by pentaho.
the class UIEESecurityUser method getUserInfo.
@Override
public IUser getUserInfo() throws KettleException {
IUser userInfo = rsm.constructUser();
userInfo.setDescription(getDescription());
userInfo.setLogin(getName());
userInfo.setName(getName());
userInfo.setUsername(getName());
userInfo.setPassword(getPassword());
if (userInfo instanceof IEEUser) {
for (IUIRole role : getAssignedRoles()) {
((IEEUser) userInfo).addRole(role.getRole());
}
}
return userInfo;
}
use of org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole 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();
}
}
Aggregations