Search in sources :

Example 1 with IUIRole

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();
    }
}
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 IUIRole

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

Example 3 with IUIRole

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();
    }
}
Also used : IUIAbsRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.abs.IUIAbsRole) KettleException(org.pentaho.di.core.exception.KettleException) XulMessageBox(org.pentaho.ui.xul.components.XulMessageBox) IAbsSecurityManager(org.pentaho.di.ui.repository.pur.services.IAbsSecurityManager) IUIRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole)

Example 4 with IUIRole

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

Example 5 with IUIRole

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

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