use of org.pentaho.platform.api.engine.security.userroledao.IUserRoleDao in project pentaho-platform by pentaho.
the class DefaultDeleteHelper method getUserList.
protected List<String> getUserList() {
IUserRoleDao userRoleDao = PentahoSystem.get(IUserRoleDao.class);
List<IPentahoUser> iusers = userRoleDao.getUsers();
return iusers.stream().map(user -> user.getUsername()).collect(Collectors.toList());
}
use of org.pentaho.platform.api.engine.security.userroledao.IUserRoleDao in project pentaho-platform by pentaho.
the class UserRoleWebService method getUserRoleSecurityInfo.
@Override
public UserRoleSecurityInfo getUserRoleSecurityInfo() throws UserRoleException {
UserRoleSecurityInfo userRoleSecurityInfo = new UserRoleSecurityInfo();
IUserRoleDao dao = getDao();
List<IPentahoUser> users = dao.getUsers();
if (users != null) {
for (IPentahoUser user : users) {
userRoleSecurityInfo.getUsers().add(ProxyPentahoUserRoleHelper.toProxyUser(user));
List<IPentahoRole> roles = dao.getUserRoles(user.getTenant(), user.getUsername());
if (roles != null) {
for (IPentahoRole role : roles) {
userRoleSecurityInfo.getAssignments().add(new UserToRoleAssignment(user.getUsername(), role.getName()));
}
}
}
}
userRoleSecurityInfo.getRoles().addAll(Arrays.asList(getRoles()));
return userRoleSecurityInfo;
}
use of org.pentaho.platform.api.engine.security.userroledao.IUserRoleDao in project pentaho-platform by pentaho.
the class UserRoleDaoResource method removeAllUsersFromRole.
/**
* Removes all users from a particular role
*
* @param tenantPath (tenant path where the user exist, null of empty string assumes default tenant)
* @param roleName (role name)
* @return
*/
@PUT
@Path("/removeAllUsersFromRole")
@Consumes({ MediaType.WILDCARD })
@Facet(name = "Unsupported")
public Response removeAllUsersFromRole(@QueryParam("tenant") String tenantPath, @QueryParam("roleName") String roleName) {
if (canAdminister()) {
try {
IUserRoleDao roleDao = getUserRoleDao();
roleDao.setRoleMembers(getTenant(tenantPath), roleName, new String[0]);
updateRolesForCurrentSession();
return Response.ok().build();
} catch (Throwable th) {
return processErrorResponse(th.getLocalizedMessage());
}
} else {
return Response.status(Response.Status.UNAUTHORIZED).build();
}
}
Aggregations