Search in sources :

Example 6 with IUIRole

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

Example 7 with IUIRole

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

Example 8 with IUIRole

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

Example 9 with IUIRole

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

Example 10 with IUIRole

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

Aggregations

IUIRole (org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole)19 HashSet (java.util.HashSet)7 IUIEEUser (org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIEEUser)7 UIRepositoryRole (org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryRole)7 Test (org.junit.Test)6 IUIUser (org.pentaho.di.ui.repository.repositoryexplorer.model.IUIUser)6 EEUserInfo (org.pentaho.di.repository.pur.model.EEUserInfo)4 IRole (org.pentaho.di.repository.pur.model.IRole)4 UIEERepositoryUser (org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIEERepositoryUser)4 ArrayList (java.util.ArrayList)3 KettleException (org.pentaho.di.core.exception.KettleException)3 UIRepositoryUser (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryUser)3 IUser (org.pentaho.di.repository.IUser)2 IUIAbsRole (org.pentaho.di.ui.repository.pur.repositoryexplorer.abs.IUIAbsRole)2 UIEESecurityUser (org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIEESecurityUser)2 IAbsSecurityManager (org.pentaho.di.ui.repository.pur.services.IAbsSecurityManager)2 XulMessageBox (org.pentaho.ui.xul.components.XulMessageBox)2 List (java.util.List)1 Before (org.junit.Before)1 Type (org.pentaho.di.repository.ObjectRecipient.Type)1