The criteria for getting into Harvard University were once a closely guarded secret.

But a discrimination trial playing out in Boston federal court is laying bare how the revered Ivy League college head-hunts, ranks and anoints the lucky few who gain entry — and it isn’t pretty.

Days into the three-week trial, the court has heard allegations that the school woos applicants with ties to big donors and courts different races based on different test scores.

The case, brought by a group called Students for Fair Admissions in 2014, alleges the university’s race-conscious admissions policy discriminates against Asian-American applicants by capping their numbers and holding them to a higher standard than other races.

But the outcome of the trial could alter affirmative action in America for years to come.

The case is being brought on behalf of anonymous Asian-Americans who did not make it into Harvard, but it’s unlikely any of them will take the stand.

The real force behind Students for Fair Admissions is Edward Blum, a 66-year-old white anti-affirmative-action activist.

Blum famously brought a case against the University of Texas on behalf of a white woman who didn’t get into the college. The case went to the Supreme Court twice, and the justices found in favor of the university in 2016, saying colleges can consider race in admissions.

The Harvard case is also likely to end up before the Supreme Court, which is now dominated by conservatives with the recent appointments of Justices Neil Gorsuch and Brett Kavanaugh. Justice Anthony Kennedy, who retired this year, was the key vote in the 2016 case.

In opening arguments Monday, Students for Fair Admissions’ lawyer said that wasn’t the goal.

“The future of affirmative action in college admissions is not on trial,” attorney Adam Mortara said.

“This trial is about what Harvard has done and is doing to Asian-American applicants, and how far Harvard has gone in its zeal to use race in the admissions process.”

Mortara argued that Asian-American applicants consistently outperform their white counterparts in academics, yet half as many students of Asian descent get into Harvard as white students.

Harvard’s lawyer countered that race is never the lone reason a student is admitted, but added that the school would be less diverse if it only took academic performance into consideration.

“Harvard cannot achieve its educational goals without considering race. Either its classes would be radically less diverse, or they would suffer in other fundamental ways, including in academic excellence,” attorney Bill Lee said, according to Courthouse News.

He warned that the outcome of the case could impact colleges across the country.

Students for Fair Admissions alleges that Harvard engages in “racial balancing” for incoming classes, which illegally discriminates against Asian-Americans.

It does this in part, the group says, through one of its measures for ranking applicants — a “personal rating” that rates traits like “likeability,” “courage” and “kindness.”

Asian-Americans are slugged with a “significant penalty” on the ratings compared with other students, while black and Hispanic students get “a significant preference,” according to the group’s own analysis of admissions data, which was performed by Duke University professor Peter Arcidiacono.

“When it comes to the score assigned by the admissions office, Asian-American applicants are assigned the lowest scores of any racial group,” the plaintiffs argue in a pretrial memorandum.

“Asian-American applicants to Harvard are just as ‘helpful,’ ‘courageous’ and ‘kind’ as white applicants.”

On the stand this week, Harvard’s longtime dean of admissions, William Fitzsimmons, acknowledged the discrepancy, but blamed high-school teachers.

“The strength of the teacher recommendations and counselor recommendations for whites is somewhat stronger than those for Asian-Americans,” he offered as one possible “factor,” according to The New York Times.

But the plaintiffs’ lawyers argued the bias begins earlier than that. They said recruitment letters sent to high-school juniors showed the school held Asian-Americans to higher standards.

The test scores used as cutoffs for which black and Hispanic students were sent letters were far lower than for Asian-Americans, they said.

And in rural states, the test-score standards were also lowered for white kids — but still not Asians.

Fitzsimmons didn’t deny the numbers, but argued the point of the letter was just to spread the good word about Harvard.

“It’s simply trying to reach out to people from all backgrounds, especially those who experience disproportionate effects of economic disadvantage,” he said, according to The Boston Globe.

Court documents released by the plaintiffs, however, show students who receive the letters are around two times more likely to be admitted than applicants who didn’t, according to the Times.

On Wednesday, Students for Fair Admissions’ attorneys argued that Harvard also rolls out the red carpet for applicants who have ties to big donors — a group that is predominantly white.

They revealed e-mails that showed how one student received the royal treatment after his family gave $1.1 million to the school over four years.

Harvard’s men’s tennis coach fired off a thank-you e-mail in 2014 to Fitzsimmons, saying that “it would mean a great deal” to see that student at Harvard, according to The Boston Globe.

Fitzsimmons wrote back saying the student would be considered for a “likely” admissions letter in October.

A year earlier, David Ellwood, the dean of Harvard’s graduate school, applauded Fitzsimmons as his “hero,” saying the admission of certain students were “all big wins” for the school.

One of the accepted applicants was connected to a donor who “has already committed to a building” and two others had “committed major money for fellowships before the decision from you,” Ellwood said in the e-mail.

The plaintiffs’ lawyer suggested Harvard accepts relatives of alumni and donors even when they are not qualified.

Fitzsimmons denied that, saying while those applicants are flagged on a secretive “dean’s list,” they are still vetted for admission by a 40-person committee.

He admitted, however, that there’s good reason to pay special attention to potential students with deep pockets.

“It is important for the long-term strength of the institution, in that we have the resources we need to, among other things, provide scholarships,” he said.

Harvard’s defense is that the Supreme Court has established that it is perfectly legal to consider race in admissions, but it argues that it has never discriminated on the basis of race.

Race may be one factor it considers when assembling its freshman class of around 1,600 students from more than 40,000 applicants, but it’s never used against an applicant, Lee said in his opening statements Monday.

“Harvard never considers an applicant’s race to be a negative,” Lee said. “If it considers race, it’s always considered in a positive way.”

He argued that Students for Fair Admissions is cherry-picking data to make its case.

“This allegation that Harvard discriminates against Asian-Americans has been made before, has been investigated before, and has been found to be meritless before,” he said.

With Wire Services