Search in sources :

Example 6 with ProxyPentahoUser

use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser in project pentaho-kettle by pentaho.

the class UserRoleHelper method convertToPentahoProxyUser.

public static ProxyPentahoUser convertToPentahoProxyUser(IUser userInfo) {
    ProxyPentahoUser user = new ProxyPentahoUser();
    user.setName(userInfo.getLogin());
    // Since we send the empty password to the client, if the client has not modified the password then we do change it
    if (!StringUtils.isEmpty(userInfo.getPassword())) {
        user.setPassword(userInfo.getPassword());
    }
    user.setDescription(userInfo.getDescription());
    return user;
}
Also used : ProxyPentahoUser(org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser)

Example 7 with ProxyPentahoUser

use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser in project pentaho-kettle by pentaho.

the class UserRoleHelper method convertFromProxyPentahoUsers.

/* EESOURCE: UPDATE SERIALVERUID */
public static List<IUser> convertFromProxyPentahoUsers(UserRoleSecurityInfo info, IRoleSupportSecurityManager rsm) {
    List<ProxyPentahoUser> users = info.getUsers();
    if (users == null || users.isEmpty()) {
        return Collections.emptyList();
    }
    List<UserToRoleAssignment> assignments = info.getAssignments();
    List<IUser> userList = new ArrayList<IUser>(users.size());
    for (ProxyPentahoUser user : users) {
        userList.add(convertFromProxyPentahoUser(user, assignments, rsm));
    }
    return userList;
}
Also used : UserToRoleAssignment(org.pentaho.platform.security.userroledao.ws.UserToRoleAssignment) ArrayList(java.util.ArrayList) IUser(org.pentaho.di.repository.IUser) ProxyPentahoUser(org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser)

Example 8 with ProxyPentahoUser

use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser in project pentaho-platform by pentaho.

the class UserRoleWebServiceBase method testSetRoles.

@Test
public void testSetRoles() throws UserRoleException {
    UserRoleDaoMock userRoleDao = PentahoSystem.get(UserRoleDaoMock.class, USER_ROLE_DAO_TXN, null);
    IUserRoleWebService service = getUserRoleWebService();
    mockUserAsAdmin(false);
    ProxyPentahoUser userObj = new ProxyPentahoUser();
    userObj.setName("test1");
    ProxyPentahoRole[] rolesObj = new ProxyPentahoRole[1];
    rolesObj[0] = new ProxyPentahoRole("testRole2");
    try {
        service.setRoles(userObj, rolesObj);
        Assert.fail();
    } catch (UserRoleException e) {
        Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
    }
    mockUserAsAdmin(true);
    userRoleDao.getUserRoles(null, "test1");
    Assert.assertEquals("testRole1", userRoleDao.getUserRoles(null, "test1").get(0).getName());
    service.setRoles(userObj, rolesObj);
    Assert.assertEquals("testRole2", userRoleDao.getUserRoles(null, "test1").get(0).getName());
}
Also used : ProxyPentahoRole(org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole) IUserRoleWebService(org.pentaho.platform.security.userroledao.ws.IUserRoleWebService) UserRoleException(org.pentaho.platform.security.userroledao.ws.UserRoleException) ProxyPentahoUser(org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser) Test(org.junit.Test)

Example 9 with ProxyPentahoUser

use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser in project pentaho-platform by pentaho.

the class UserRoleWebServiceBase method testGetRolesForUser.

@Test
public void testGetRolesForUser() throws UserRoleException {
    IUserRoleWebService service = getUserRoleWebService();
    mockUserAsAdmin(false);
    ProxyPentahoUser userObj = new ProxyPentahoUser();
    userObj.setName("test1");
    try {
        service.getRolesForUser(userObj);
        Assert.fail();
    } catch (UserRoleException e) {
        Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
    }
    mockUserAsAdmin(true);
    ProxyPentahoRole[] roles = service.getRolesForUser(userObj);
    Assert.assertEquals(1, roles.length);
}
Also used : ProxyPentahoRole(org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole) IUserRoleWebService(org.pentaho.platform.security.userroledao.ws.IUserRoleWebService) UserRoleException(org.pentaho.platform.security.userroledao.ws.UserRoleException) ProxyPentahoUser(org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser) Test(org.junit.Test)

Example 10 with ProxyPentahoUser

use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser in project pentaho-platform by pentaho.

the class UserRoleWebServiceBase method testUpdateUser.

@Test
public void testUpdateUser() throws UserRoleException {
    UserRoleDaoMock userRoleDao = PentahoSystem.get(UserRoleDaoMock.class, USER_ROLE_DAO_TXN, null);
    IUserRoleWebService service = getUserRoleWebService();
    mockUserAsAdmin(false);
    ProxyPentahoUser userObj = new ProxyPentahoUser();
    userObj.setName("test1");
    userObj.setDescription("testUpdateUser");
    userObj.setPassword("newpass");
    try {
        service.updateUser(userObj);
        Assert.fail();
    } catch (UserRoleException e) {
        Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
    }
    mockUserAsAdmin(true);
    Assert.assertEquals("test", userRoleDao.getUser(null, "test1").getDescription());
    service.updateUser(userObj);
    Assert.assertEquals("testUpdateUser", userRoleDao.getUser(null, "test1").getDescription());
}
Also used : IUserRoleWebService(org.pentaho.platform.security.userroledao.ws.IUserRoleWebService) UserRoleException(org.pentaho.platform.security.userroledao.ws.UserRoleException) ProxyPentahoUser(org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser) Test(org.junit.Test)

Aggregations

ProxyPentahoUser (org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser)24 Test (org.junit.Test)15 UserRoleException (org.pentaho.platform.security.userroledao.ws.UserRoleException)14 IUserRoleWebService (org.pentaho.platform.security.userroledao.ws.IUserRoleWebService)11 IUser (org.pentaho.di.repository.IUser)7 KettleException (org.pentaho.di.core.exception.KettleException)5 JSONException (org.json.JSONException)4 UserRoleHelper.convertFromProxyPentahoUser (org.pentaho.di.repository.pur.UserRoleHelper.convertFromProxyPentahoUser)4 ProxyPentahoRole (org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole)4 IRoleSupportSecurityManager (org.pentaho.di.ui.repository.pur.services.IRoleSupportSecurityManager)3 IEEUser (org.pentaho.di.repository.pur.model.IEEUser)2 UserRoleWebService (org.pentaho.platform.security.userroledao.ws.UserRoleWebService)2 UserToRoleAssignment (org.pentaho.platform.security.userroledao.ws.UserToRoleAssignment)2 ArrayList (java.util.ArrayList)1 UserInfo (org.pentaho.di.repository.UserInfo)1 EEUserInfo (org.pentaho.di.repository.pur.model.EEUserInfo)1 AlreadyExistsException (org.pentaho.platform.api.engine.security.userroledao.AlreadyExistsException)1 IPentahoUser (org.pentaho.platform.api.engine.security.userroledao.IPentahoUser)1