use of org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole 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.IUIRole in project pentaho-kettle by pentaho.
the class UIEESecurityUserTest method testAddUser.
@Test
public void testAddUser() throws Exception {
try {
UIEESecurityUser user = new UIEESecurityUser(sm);
List<IUIRole> rroles = new ArrayList<IUIRole>();
for (IRole EERoleInfo : roles) {
rroles.add(new UIRepositoryRole(EERoleInfo));
}
user.clear();
user.setAvailableRoles(rroles);
user.setMode(Mode.ADD);
user.setName("newuser");
user.setPassword("newpassword");
user.setDescription("new description");
List<Object> rolesToAssign = new ArrayList<Object>();
rolesToAssign.add(new UIRepositoryRole(ctoRole));
rolesToAssign.add(new UIRepositoryRole(isRole));
rolesToAssign.add(new UIRepositoryRole(adminRole));
rolesToAssign.add(new UIRepositoryRole(authenticatedRole));
user.assignRoles(rolesToAssign);
assertEquals(user.getMode(), Mode.ADD);
// $NON-NLS-1$
assertEquals(user.getName(), "newuser");
// $NON-NLS-1$
assertEquals(user.getPassword(), "newpassword");
// $NON-NLS-1$
assertEquals(user.getDescription(), "new description");
Assert.assertTrue(contains(user.getAssignedRoles(), new UIRepositoryRole(adminRole)));
Assert.assertTrue(contains(user.getAssignedRoles(), new UIRepositoryRole(authenticatedRole)));
Assert.assertTrue(contains(user.getAssignedRoles(), new UIRepositoryRole(ctoRole)));
Assert.assertTrue(contains(user.getAssignedRoles(), new UIRepositoryRole(isRole)));
} catch (Exception e) {
Assert.fail();
}
}
use of org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole in project pentaho-kettle by pentaho.
the class AbsController method applySystemRoleActionPermission.
/**
* Save the permission for the selected system role
*/
public void applySystemRoleActionPermission() {
XulMessageBox messageBox = this.getMessageBox();
IUIRole role = null;
IUIAbsRole absRole = null;
try {
role = absSecurity.getSelectedSystemRole();
if (role instanceof IUIAbsRole) {
absRole = (IUIAbsRole) role;
} else {
throw new IllegalStateException();
}
((IAbsSecurityManager) service).setLogicalRoles(absRole.getName(), absRole.getLogicalRoles());
// $NON-NLS-1$
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Success"));
// $NON-NLS-1$
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
// $NON-NLS-1$
messageBox.setMessage(BaseMessages.getString(PKG, "AbsController.RoleActionPermission.Success"));
messageBox.open();
// Refresh permissions in open tabs
SpoonPluginManager.getInstance().notifyLifecycleListeners(SpoonLifecycleListener.SpoonLifeCycleEvent.REPOSITORY_CHANGED);
} catch (KettleException e) {
// $NON-NLS-1$
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
// $NON-NLS-1$
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
messageBox.setMessage(BaseMessages.getString(PKG, "AbsController.RoleActionPermission.UnableToApplyPermissions", role.getName(), // $NON-NLS-1$
e.getLocalizedMessage()));
messageBox.open();
}
}
use of org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole in project pentaho-kettle by pentaho.
the class UIEERepositoryUser method setRoles.
public void setRoles(Set<IUIRole> roles) {
Set<IRole> roleSet = new HashSet<IRole>();
for (IUIRole role : roles) {
roleSet.add(role.getRole());
}
eeUser.setRoles(roleSet);
}
use of org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole 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));
}
}
Aggregations