Search in sources :

Example 1 with IEEUser

use of org.pentaho.di.repository.pur.model.IEEUser in project pentaho-kettle by pentaho.

the class UserRoleDelegate method createUser.

public void createUser(IUser newUser) throws KettleException {
    ensureHasPermissions();
    ProxyPentahoUser user = UserRoleHelper.convertToPentahoProxyUser(newUser);
    try {
        ProxyPentahoUser[] existingUsers = userRoleWebService.getUsers();
        if (existsAmong(existingUsers, user)) {
            throw userExistsException();
        }
    } catch (UserRoleException e) {
        throw cannotCreateUserException(newUser, e);
    }
    try {
        userRoleWebService.createUser(user);
        if (newUser instanceof IEEUser) {
            userRoleWebService.setRoles(user, UserRoleHelper.convertToPentahoProxyRoles(((IEEUser) newUser).getRoles()));
        }
        lookupCache.insertUserToLookupSet(newUser);
        fireUserRoleListChange();
    } catch (Exception e) {
        // it is the only way to determine AlreadyExistsException
        if (e.getCause().toString().contains("org.pentaho.platform.api.engine.security.userroledao.AlreadyExistsException")) {
            throw userExistsException();
        }
        throw cannotCreateUserException(newUser, e);
    }
}
Also used : UserRoleException(org.pentaho.platform.security.userroledao.ws.UserRoleException) ProxyPentahoUser(org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser) IEEUser(org.pentaho.di.repository.pur.model.IEEUser) KettleException(org.pentaho.di.core.exception.KettleException) UserRoleException(org.pentaho.platform.security.userroledao.ws.UserRoleException) JSONException(org.json.JSONException)

Example 2 with IEEUser

use of org.pentaho.di.repository.pur.model.IEEUser in project pentaho-kettle by pentaho.

the class UserRoleDelegate method updateUser.

public void updateUser(IUser user) throws KettleException {
    ensureHasPermissions();
    try {
        ProxyPentahoUser proxyUser = UserRoleHelper.convertToPentahoProxyUser(user);
        userRoleWebService.updateUser(proxyUser);
        if (user instanceof IEEUser) {
            userRoleWebService.setRoles(proxyUser, UserRoleHelper.convertToPentahoProxyRoles(((IEEUser) user).getRoles()));
        }
        lookupCache.updateUserInLookupSet(user);
        fireUserRoleListChange();
    } catch (Exception e) {
        throw new KettleException(BaseMessages.getString(UserRoleDelegate.class, "UserRoleDelegate.ERROR_0007_UNABLE_TO_UPDATE_USER", user.getLogin()), // $NON-NLS-1$
        e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ProxyPentahoUser(org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser) IEEUser(org.pentaho.di.repository.pur.model.IEEUser) KettleException(org.pentaho.di.core.exception.KettleException) UserRoleException(org.pentaho.platform.security.userroledao.ws.UserRoleException) JSONException(org.json.JSONException)

Example 3 with IEEUser

use of org.pentaho.di.repository.pur.model.IEEUser in project pentaho-kettle by pentaho.

the class UIEESecurityUser method getUserInfo.

@Override
public IUser getUserInfo() throws KettleException {
    IUser userInfo = rsm.constructUser();
    userInfo.setDescription(getDescription());
    userInfo.setLogin(getName());
    userInfo.setName(getName());
    userInfo.setUsername(getName());
    userInfo.setPassword(getPassword());
    if (userInfo instanceof IEEUser) {
        for (IUIRole role : getAssignedRoles()) {
            ((IEEUser) userInfo).addRole(role.getRole());
        }
    }
    return userInfo;
}
Also used : IUIUser(org.pentaho.di.ui.repository.repositoryexplorer.model.IUIUser) IUser(org.pentaho.di.repository.IUser) IUIEEUser(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIEEUser) IEEUser(org.pentaho.di.repository.pur.model.IEEUser) IUIRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole)

Example 4 with IEEUser

use of org.pentaho.di.repository.pur.model.IEEUser in project pentaho-kettle by pentaho.

the class UserRoleHelper method convertToUserInfo.

public static IUser convertToUserInfo(ProxyPentahoUser user, ProxyPentahoRole[] roles, IRoleSupportSecurityManager rsm) {
    IUser userInfo = null;
    try {
        userInfo = rsm.constructUser();
        userInfo.setDescription(user.getDescription());
        userInfo.setPassword(user.getPassword());
        userInfo.setLogin(user.getName());
        userInfo.setName(user.getName());
        if (userInfo instanceof IEEUser) {
            ((IEEUser) userInfo).setRoles(convertToSetFromProxyPentahoRoles(roles, rsm));
        }
    } catch (KettleException ke) {
        ke.printStackTrace();
    }
    return userInfo;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) IUser(org.pentaho.di.repository.IUser) IEEUser(org.pentaho.di.repository.pur.model.IEEUser)

Example 5 with IEEUser

use of org.pentaho.di.repository.pur.model.IEEUser in project pentaho-kettle by pentaho.

the class UserRoleHelper method convertFromProxyPentahoUser.

public static IUser convertFromProxyPentahoUser(IUserRoleWebService userRoleWebService, ProxyPentahoUser user, UserRoleLookupCache lookupCache, IRoleSupportSecurityManager rsm) {
    IUser userInfo = null;
    try {
        userInfo = rsm.constructUser();
        userInfo.setDescription(user.getDescription());
        userInfo.setPassword(user.getPassword());
        userInfo.setLogin(user.getName());
        userInfo.setName(user.getName());
        try {
            if (userInfo instanceof IEEUser) {
                ((IEEUser) userInfo).setRoles(convertToSetFromProxyPentahoRoles(userRoleWebService.getRolesForUser(user), lookupCache));
            }
        } catch (UserRoleException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } catch (KettleException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    return userInfo;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) IUser(org.pentaho.di.repository.IUser) UserRoleException(org.pentaho.platform.security.userroledao.ws.UserRoleException) IEEUser(org.pentaho.di.repository.pur.model.IEEUser)

Aggregations

IEEUser (org.pentaho.di.repository.pur.model.IEEUser)7 KettleException (org.pentaho.di.core.exception.KettleException)5 IUser (org.pentaho.di.repository.IUser)5 UserRoleException (org.pentaho.platform.security.userroledao.ws.UserRoleException)3 JSONException (org.json.JSONException)2 ProxyPentahoUser (org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser)2 IUIEEUser (org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIEEUser)1 IUIRole (org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole)1 IUIUser (org.pentaho.di.ui.repository.repositoryexplorer.model.IUIUser)1