U.S. District Judge George O'Toole Jr. in Boston ruled that the labor unions lacked legal standing to challenge the program.