Search in sources :

Example 6 with IRoleSupportSecurityManager

use of org.pentaho.di.ui.repository.pur.services.IRoleSupportSecurityManager in project pentaho-kettle by pentaho.

the class UserRoleHelperTest method convertFromProxyPentahoUser_CopiesDataFromInput.

@Test
public void convertFromProxyPentahoUser_CopiesDataFromInput() throws Exception {
    IRoleSupportSecurityManager manager = mockSecurityManager(false);
    ProxyPentahoUser pentahoUser = pentahoUser("name");
    pentahoUser.setPassword("password");
    pentahoUser.setDescription("desc");
    pentahoUser.setEnabled(true);
    IUser user = convertFromProxyPentahoUser(pentahoUser, Collections.<UserToRoleAssignment>emptyList(), manager);
    assertNotNull(user);
    assertEquals(pentahoUser.getName(), user.getName());
    assertEquals(pentahoUser.getName(), user.getLogin());
    assertEquals(pentahoUser.getPassword(), user.getPassword());
    assertEquals(pentahoUser.getDescription(), user.getDescription());
    assertEquals(pentahoUser.getEnabled(), user.isEnabled());
}
Also used : IRoleSupportSecurityManager(org.pentaho.di.ui.repository.pur.services.IRoleSupportSecurityManager) IUser(org.pentaho.di.repository.IUser) ProxyPentahoUser(org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser) UserRoleHelper.convertFromProxyPentahoUser(org.pentaho.di.repository.pur.UserRoleHelper.convertFromProxyPentahoUser) Test(org.junit.Test)

Example 7 with IRoleSupportSecurityManager

use of org.pentaho.di.ui.repository.pur.services.IRoleSupportSecurityManager in project pentaho-kettle by pentaho.

the class UserRoleHelperTest method convertFromProxyPentahoUsers_CopiesEachUser.

@Test
public void convertFromProxyPentahoUsers_CopiesEachUser() throws Exception {
    UserRoleSecurityInfo info = new UserRoleSecurityInfo();
    info.setUsers(Arrays.asList(pentahoUser("user1"), pentahoUser("user2")));
    IRoleSupportSecurityManager manager = mockSecurityManager(false);
    List<IUser> users = convertFromProxyPentahoUsers(info, manager);
    assertNotNull(users);
    assertEquals(2, users.size());
    assertEquals("user1", users.get(0).getName());
    assertEquals("user2", users.get(1).getName());
}
Also used : IRoleSupportSecurityManager(org.pentaho.di.ui.repository.pur.services.IRoleSupportSecurityManager) UserRoleSecurityInfo(org.pentaho.platform.security.userroledao.ws.UserRoleSecurityInfo) IUser(org.pentaho.di.repository.IUser) Test(org.junit.Test)

Example 8 with IRoleSupportSecurityManager

use of org.pentaho.di.ui.repository.pur.services.IRoleSupportSecurityManager in project pentaho-kettle by pentaho.

the class EESecurityController method updateRole.

/**
 * updateRole method is called when user has click ok on a edit role dialog. The method updates the role
 *
 * @throws Exception
 */
private void updateRole() {
    if (service != null) {
        try {
            IUIRole uiRole = eeSecurity.getSelectedRole();
            Set<IUIUser> previousUserList = new HashSet<IUIUser>();
            previousUserList.addAll(uiRole.getUsers());
            uiRole.setDescription(securityRole.getDescription());
            uiRole.setUsers(new HashSet<IUIUser>(securityRole.getAssignedUsers()));
            ((IRoleSupportSecurityManager) service).updateRole(uiRole.getRole());
            eeSecurity.updateRole(uiRole, previousUserList);
            roleDialog.hide();
        } catch (Throwable th) {
            // $NON-NLS-1$
            messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
            // $NON-NLS-1$
            messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
            messageBox.setMessage(// $NON-NLS-1$
            BaseMessages.getString(PKG, "UpdateRole.UnableToUpdateRole", th.getLocalizedMessage()));
            messageBox.open();
        }
    }
}
Also used : IRoleSupportSecurityManager(org.pentaho.di.ui.repository.pur.services.IRoleSupportSecurityManager) IUIUser(org.pentaho.di.ui.repository.repositoryexplorer.model.IUIUser) IUIRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole) HashSet(java.util.HashSet)

Aggregations

IRoleSupportSecurityManager (org.pentaho.di.ui.repository.pur.services.IRoleSupportSecurityManager)8 Test (org.junit.Test)5 IUser (org.pentaho.di.repository.IUser)5 UserRoleHelper.convertFromProxyPentahoUser (org.pentaho.di.repository.pur.UserRoleHelper.convertFromProxyPentahoUser)3 ProxyPentahoUser (org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser)3 EEUserInfo (org.pentaho.di.repository.pur.model.EEUserInfo)2 IRole (org.pentaho.di.repository.pur.model.IRole)2 IUIRole (org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole)2 UserRoleSecurityInfo (org.pentaho.platform.security.userroledao.ws.UserRoleSecurityInfo)2 HashSet (java.util.HashSet)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 KettleException (org.pentaho.di.core.exception.KettleException)1 UserInfo (org.pentaho.di.repository.UserInfo)1 EERoleInfo (org.pentaho.di.repository.pur.model.EERoleInfo)1 IUIUser (org.pentaho.di.ui.repository.repositoryexplorer.model.IUIUser)1 UserToRoleAssignment (org.pentaho.platform.security.userroledao.ws.UserToRoleAssignment)1