Search in sources :

Example 6 with UserToRoleAssignment

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

the class UserRoleHelper method getRolesForUser.

public static Set<IRole> getRolesForUser(String name, List<UserToRoleAssignment> assignments, IRoleSupportSecurityManager rsm) {
    if (assignments == null || assignments.isEmpty()) {
        return Collections.emptySet();
    }
    Set<IRole> roles = new HashSet<IRole>(assignments.size());
    for (UserToRoleAssignment assignment : assignments) {
        if (name.equals(assignment.getUserId())) {
            IRole role = null;
            try {
                role = rsm.constructRole();
            } catch (KettleException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (role != null) {
                role.setName(assignment.getRoleId());
                roles.add(role);
            }
        }
    }
    return roles;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) IRole(org.pentaho.di.repository.pur.model.IRole) UserToRoleAssignment(org.pentaho.platform.security.userroledao.ws.UserToRoleAssignment) HashSet(java.util.HashSet)

Aggregations

UserToRoleAssignment (org.pentaho.platform.security.userroledao.ws.UserToRoleAssignment)6 ArrayList (java.util.ArrayList)3 IRole (org.pentaho.di.repository.pur.model.IRole)3 HashSet (java.util.HashSet)2 KettleException (org.pentaho.di.core.exception.KettleException)2 IUser (org.pentaho.di.repository.IUser)2 ProxyPentahoRole (org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole)2 ProxyPentahoUser (org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser)2 Test (org.junit.Test)1 UserRoleHelper.convertFromProxyPentahoUser (org.pentaho.di.repository.pur.UserRoleHelper.convertFromProxyPentahoUser)1 EEUserInfo (org.pentaho.di.repository.pur.model.EEUserInfo)1 IRoleSupportSecurityManager (org.pentaho.di.ui.repository.pur.services.IRoleSupportSecurityManager)1