Search in sources :

Example 1 with UserToRoleAssignment

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

the class UserRoleHelperTest method convertFromProxyPentahoUser_CopiesRolesForEeUser.

@Test
public void convertFromProxyPentahoUser_CopiesRolesForEeUser() throws Exception {
    IRoleSupportSecurityManager manager = mockSecurityManager(true);
    ProxyPentahoUser pentahoUser = pentahoUser("name");
    List<UserToRoleAssignment> assignments = Collections.singletonList(new UserToRoleAssignment("name", "role"));
    EEUserInfo user = (EEUserInfo) convertFromProxyPentahoUser(pentahoUser, assignments, manager);
    assertNotNull(user);
    assertEquals(pentahoUser.getName(), user.getName());
    assertEquals(1, user.getRoles().size());
    assertEquals("role", user.getRoles().iterator().next().getName());
}
Also used : IRoleSupportSecurityManager(org.pentaho.di.ui.repository.pur.services.IRoleSupportSecurityManager) UserToRoleAssignment(org.pentaho.platform.security.userroledao.ws.UserToRoleAssignment) EEUserInfo(org.pentaho.di.repository.pur.model.EEUserInfo) ProxyPentahoUser(org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser) UserRoleHelper.convertFromProxyPentahoUser(org.pentaho.di.repository.pur.UserRoleHelper.convertFromProxyPentahoUser) Test(org.junit.Test)

Example 2 with UserToRoleAssignment

use of org.pentaho.platform.security.userroledao.ws.UserToRoleAssignment 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 3 with UserToRoleAssignment

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

the class UserRoleHelper method convertToListFromProxyPentahoDefaultRoles.

public static List<IRole> convertToListFromProxyPentahoDefaultRoles(UserRoleSecurityInfo info, IRoleSupportSecurityManager rsm) {
    List<IRole> roleList = new ArrayList<IRole>();
    List<ProxyPentahoRole> roles = info.getDefaultRoles();
    List<UserToRoleAssignment> assignments = info.getAssignments();
    for (ProxyPentahoRole role : roles) {
        roleList.add(convertFromProxyPentahoRole(role, assignments, rsm));
    }
    return roleList;
}
Also used : IRole(org.pentaho.di.repository.pur.model.IRole) UserToRoleAssignment(org.pentaho.platform.security.userroledao.ws.UserToRoleAssignment) ProxyPentahoRole(org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole) ArrayList(java.util.ArrayList)

Example 4 with UserToRoleAssignment

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

the class UserRoleHelper method getUsersForRole.

public static Set<IUser> getUsersForRole(String name, List<UserToRoleAssignment> assignments, IRoleSupportSecurityManager rsm) {
    Set<IUser> users = new HashSet<IUser>();
    for (UserToRoleAssignment assignment : assignments) {
        if (name.equals(assignment.getRoleId())) {
            IUser user = null;
            try {
                user = rsm.constructUser();
            } catch (KettleException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            user.setLogin(assignment.getUserId());
            users.add(user);
        }
    }
    return users;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) UserToRoleAssignment(org.pentaho.platform.security.userroledao.ws.UserToRoleAssignment) IUser(org.pentaho.di.repository.IUser) HashSet(java.util.HashSet)

Example 5 with UserToRoleAssignment

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

the class UserRoleHelper method convertToListFromProxyPentahoRoles.

public static List<IRole> convertToListFromProxyPentahoRoles(UserRoleSecurityInfo info, IRoleSupportSecurityManager rsm) {
    List<IRole> roleList = new ArrayList<IRole>();
    List<ProxyPentahoRole> roles = info.getRoles();
    List<UserToRoleAssignment> assignments = info.getAssignments();
    for (ProxyPentahoRole role : roles) {
        roleList.add(convertFromProxyPentahoRole(role, assignments, rsm));
    }
    return roleList;
}
Also used : IRole(org.pentaho.di.repository.pur.model.IRole) UserToRoleAssignment(org.pentaho.platform.security.userroledao.ws.UserToRoleAssignment) ProxyPentahoRole(org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole) ArrayList(java.util.ArrayList)

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