Search in sources :

Example 16 with ProxyPentahoUser

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

the class UserRoleDelegate method deleteUser.

public void deleteUser(String name) throws KettleException {
    ensureHasPermissions();
    try {
        ProxyPentahoUser user = userRoleWebService.getUser(name);
        if (user != null) {
            ProxyPentahoUser[] users = new ProxyPentahoUser[1];
            users[0] = user;
            userRoleWebService.deleteUsers(users);
            fireUserRoleListChange();
        } else {
            throw new KettleException(BaseMessages.getString(UserRoleDelegate.class, "UserRoleDelegate.ERROR_0004_UNABLE_TO_DELETE_USER", // $NON-NLS-1$
            name));
        }
    } catch (Exception e) {
        throw new KettleException(BaseMessages.getString(UserRoleDelegate.class, "UserRoleDelegate.ERROR_0004_UNABLE_TO_DELETE_USER", name), // $NON-NLS-1$
        e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ProxyPentahoUser(org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser) KettleException(org.pentaho.di.core.exception.KettleException) UserRoleException(org.pentaho.platform.security.userroledao.ws.UserRoleException) JSONException(org.json.JSONException)

Example 17 with ProxyPentahoUser

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

the class UserRoleDelegate method getUser.

public IUser getUser(String name) throws KettleException {
    ensureHasPermissions();
    IUser userInfo = null;
    try {
        ProxyPentahoUser user = userRoleWebService.getUser(name);
        if (user != null && user.getName().equals(name)) {
            userInfo = UserRoleHelper.convertToUserInfo(user, userRoleWebService.getRolesForUser(user), rsm);
        }
    } catch (Exception e) {
        throw new KettleException(BaseMessages.getString(UserRoleDelegate.class, "UserRoleDelegate.ERROR_0005_UNABLE_TO_GET_USER", name), // $NON-NLS-1$
        e);
    }
    return userInfo;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) IUser(org.pentaho.di.repository.IUser) ProxyPentahoUser(org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser) KettleException(org.pentaho.di.core.exception.KettleException) UserRoleException(org.pentaho.platform.security.userroledao.ws.UserRoleException) JSONException(org.json.JSONException)

Example 18 with ProxyPentahoUser

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

the class UserRoleHelper method convertToPentahoProxyUsers.

public static ProxyPentahoUser[] convertToPentahoProxyUsers(Set<IUser> users) {
    ProxyPentahoUser[] proxyUsers = new ProxyPentahoUser[users.size()];
    int i = 0;
    for (IUser user : users) {
        proxyUsers[i++] = convertToPentahoProxyUser(user);
    }
    return proxyUsers;
}
Also used : IUser(org.pentaho.di.repository.IUser) ProxyPentahoUser(org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser)

Example 19 with ProxyPentahoUser

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

the class UserRoleHelper method convertToPentahoProxyUsers.

public static ProxyPentahoUser[] convertToPentahoProxyUsers(List<IUser> users) {
    ProxyPentahoUser[] proxyUsers = new ProxyPentahoUser[users.size()];
    int i = 0;
    for (IUser user : users) {
        proxyUsers[i++] = convertToPentahoProxyUser(user);
    }
    return proxyUsers;
}
Also used : IUser(org.pentaho.di.repository.IUser) ProxyPentahoUser(org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser)

Example 20 with ProxyPentahoUser

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

the class UserRoleWebServiceBase method testGetUsersForRole.

@Test
public void testGetUsersForRole() throws UserRoleException {
    IUserRoleWebService service = getUserRoleWebService();
    mockUserAsAdmin(false);
    ProxyPentahoRole roleObj = new ProxyPentahoRole("testRole1");
    try {
        service.getUsersForRole(roleObj);
        Assert.fail();
    } catch (UserRoleException e) {
        Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
    }
    mockUserAsAdmin(true);
    ProxyPentahoUser[] userObjs = service.getUsersForRole(roleObj);
    Assert.assertEquals(1, userObjs.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)

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