Search in sources :

Example 1 with IUIEEUser

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();
    }
}
Also used : UIEERepositoryUser(org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIEERepositoryUser) UIRepositoryRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryRole) IUIUser(org.pentaho.di.ui.repository.repositoryexplorer.model.IUIUser) EEUserInfo(org.pentaho.di.repository.pur.model.EEUserInfo) IUIEEUser(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIEEUser) IUIRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with IUIEEUser

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);
}
Also used : IUIUser(org.pentaho.di.ui.repository.repositoryexplorer.model.IUIUser) IUIEEUser(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIEEUser)

Example 3 with IUIEEUser

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));
    }
}
Also used : IUIEEUser(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIEEUser) IUIRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole)

Example 4 with IUIEEUser

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);
}
Also used : IUIEEUser(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIEEUser) IUIRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole)

Example 5 with IUIEEUser

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()));
        }
    }
}
Also used : IUIEEUser(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIEEUser) IUIRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole)

Aggregations

IUIEEUser (org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIEEUser)7 IUIRole (org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole)6 IUIUser (org.pentaho.di.ui.repository.repositoryexplorer.model.IUIUser)3 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Test (org.junit.Test)1 KettleException (org.pentaho.di.core.exception.KettleException)1 Type (org.pentaho.di.repository.ObjectRecipient.Type)1 EEUserInfo (org.pentaho.di.repository.pur.model.EEUserInfo)1 UIEERepositoryUser (org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIEERepositoryUser)1 UIRepositoryRole (org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryRole)1 UIObjectCreationException (org.pentaho.di.ui.repository.repositoryexplorer.model.UIObjectCreationException)1 Mode (org.pentaho.di.ui.repository.repositoryexplorer.model.UISecurity.Mode)1 BindingConvertor (org.pentaho.ui.xul.binding.BindingConvertor)1