Search in sources :

Example 11 with IUIRole

use of org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole in project pentaho-kettle by pentaho.

the class UIEESecurityTest method testAddUser.

@Test
public void testAddUser() throws Exception {
    try {
        security.setSelectedDeck(ObjectRecipient.Type.USER);
        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);
        assertEquals(security.getSelectedUser(), userToAdd);
        assertEquals(security.getSelectedDeck(), ObjectRecipient.Type.USER);
        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) EEUserInfo(org.pentaho.di.repository.pur.model.EEUserInfo) IUIRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 12 with IUIRole

use of org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole in project pentaho-kettle by pentaho.

the class UIEESecurityTest method testRemoveUser.

@Test
public void testRemoveUser() 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();
        int removeUserIndex = security.getSelectedUserIndex();
        security.removeUser("newuser");
        assertEquals(security.getSelectedUserIndex(), removeUserIndex - 1);
        assertEquals(security.getUserList().size(), 4);
    } 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) EEUserInfo(org.pentaho.di.repository.pur.model.EEUserInfo) IUIRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 13 with IUIRole

use of org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole in project pentaho-kettle by pentaho.

the class UIEESecurityTest method init.

@Before
public void init() {
    roles.add(adminRole);
    roles.add(anonymousRole);
    roles.add(authenticatedRole);
    roles.add(ceoRole);
    roles.add(ctoRole);
    roles.add(devRole);
    roles.add(devmgrRole);
    roles.add(isRole);
    joeUser = new EEUserInfo("joe", "password", "joe", "joe", true);
    patUser = new EEUserInfo("pat", "password", "pat", "pat", true);
    suzyUser = new EEUserInfo("suzy", "password", "suzy", "suzy", true);
    tiffanyUser = new EEUserInfo("tiffany", "password", "tiffany", "tiffany", true);
    joeUser.addRole(roles.get(0));
    joeUser.addRole(roles.get(2));
    joeUser.addRole(roles.get(3));
    suzyUser.addRole(roles.get(2));
    suzyUser.addRole(roles.get(4));
    suzyUser.addRole(roles.get(7));
    patUser.addRole(roles.get(2));
    patUser.addRole(roles.get(5));
    tiffanyUser.addRole(roles.get(2));
    tiffanyUser.addRole(roles.get(5));
    tiffanyUser.addRole(roles.get(6));
    adminRole.addUser(joeUser);
    adminRole.addUser(patUser);
    anonymousRole.addUser(tiffanyUser);
    authenticatedRole.addUser(joeUser);
    authenticatedRole.addUser(patUser);
    authenticatedRole.addUser(suzyUser);
    authenticatedRole.addUser(tiffanyUser);
    ceoRole.addUser(joeUser);
    ctoRole.addUser(patUser);
    devmgrRole.addUser(joeUser);
    devmgrRole.addUser(patUser);
    isRole.addUser(joeUser);
    isRole.addUser(suzyUser);
    users.add(joeUser);
    users.add(patUser);
    users.add(suzyUser);
    users.add(tiffanyUser);
    rroles = new ArrayList<IUIRole>();
    for (IRole EERoleInfo : roles) {
        IUIRole role = new UIRepositoryRole(EERoleInfo);
        rroles.add(role);
    }
    rusers = new ArrayList<IUIUser>();
    for (IUser eEUserInfo : users) {
        rusers.add(new UIRepositoryUser(eEUserInfo));
    }
    security.setUserList(rusers);
    security.setRoleList(rroles);
}
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) IUIUser(org.pentaho.di.ui.repository.repositoryexplorer.model.IUIUser) EEUserInfo(org.pentaho.di.repository.pur.model.EEUserInfo) IUIUser(org.pentaho.di.ui.repository.repositoryexplorer.model.IUIUser) IUser(org.pentaho.di.repository.IUser) UIRepositoryUser(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryUser) IUIRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole) Before(org.junit.Before)

Example 14 with IUIRole

use of org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole in project pentaho-kettle by pentaho.

the class UIEESecurityUserTest method testEditUser.

@Test
public void testEditUser() throws Exception {
    try {
        UIEESecurityUser user = new UIEESecurityUser(sm);
        List<IUIRole> rroles = new ArrayList<IUIRole>();
        for (IRole EERoleInfo : roles) {
            rroles.add(new UIRepositoryRole(EERoleInfo));
        }
        user.setUser(new UIRepositoryUser(joeUser), rroles);
        user.setMode(Mode.EDIT);
        user.setPassword("newpassword");
        user.setDescription("new description");
        List<Object> rolesToAssign1 = new ArrayList<Object>();
        rolesToAssign1.add(new UIRepositoryRole(adminRole));
        rolesToAssign1.add(new UIRepositoryRole(authenticatedRole));
        user.assignRoles(rolesToAssign1);
        List<Object> rolesToAssign = new ArrayList<Object>();
        rolesToAssign.add(new UIRepositoryRole(ctoRole));
        rolesToAssign.add(new UIRepositoryRole(isRole));
        List<Object> rolesToUnAssign = new ArrayList<Object>();
        rolesToUnAssign.add(new UIRepositoryRole(adminRole));
        rolesToUnAssign.add(new UIRepositoryRole(authenticatedRole));
        user.assignRoles(rolesToAssign);
        user.unassignRoles(rolesToUnAssign);
        // Should have exactly 7 roles
        assertEquals(user.getMode(), Mode.EDIT);
        // $NON-NLS-1$
        assertEquals(user.getPassword(), "newpassword");
        // $NON-NLS-1$
        assertEquals(user.getDescription(), "new description");
        Assert.assertFalse(contains(user.getAssignedRoles(), new UIRepositoryRole(adminRole)));
        Assert.assertFalse(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) UIRepositoryUser(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryUser) IUIRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole) UIEESecurityUser(org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIEESecurityUser) Test(org.junit.Test)

Example 15 with IUIRole

use of org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole in project pentaho-kettle by pentaho.

the class AbsController method applyRoleActionPermission.

/**
 * Save the permission for the selected role
 */
public void applyRoleActionPermission() {
    XulMessageBox messageBox = this.getMessageBox();
    IUIRole role = null;
    IUIAbsRole absRole = null;
    try {
        role = absSecurity.getSelectedRole();
        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)

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