The University of Hawaii didn't violate First Amendment rights when it denied a teaching certificate for a Caltech-educated aspiring high school teacher who expressed views condoning adults having sex with minors, a panel of federal appeals court judges ruled Tuesday.

Mark Oyama earned a bachelor's degree in mathematics from the California Institute of Technology and a master's degree in physics from the University of Hawaii. In 2010, he enrolled in the secondary education certification program at the University of Hawaii's Manoa campus, which is the state's only nationally accredited institution that recommends students for certification as secondary school teachers.

"Oyama's statements concerning sexual relationships between adults and children were of central concern to the faculty," according to a ruling by the panel of judges on the 9th Circuit Court of Appeals.

In a class assignment he wrote: "Personally I think that online child predation should be legal, and find it ridiculous that one could be arrested for comments they make on the Internet." He went on to write that "real life child predation should be legal" as long as it's consensual and that the age of consent should be "either 0, or whatever age a child is when puberty begins."

When a professor discussed the statements with Oyama, he said it would be fine for a 12-year-old student to have a consensual relationship with a teacher, but that he would obey the law and report the relationship, according to the ruling.

Oyama made other comments his professors found concerning, such as disabled students being "fakers."

The comments were relevant in determining whether he should be allowed to work as a public school teacher, the panel concluded, and the university's decision was "directly related to defined and established professional standards" at state and national levels.

"Therefore, the university's decision was, by necessity, prospective in nature," the ruling said. "Oyama stood in the doorway of the teaching profession; he was not at liberty to step inside and break the rules. But that does not mean that the university was obligated to invite him in. Rather, the university could look to what Oyama said as an indication of what he would do once certified."

The ruling is troubling because it allows the university to censor someone's opinions that aren't acted upon, said Oyama's attorney, Eric Seitz, describing his client as a socially awkward nerd.

"To me, it is outrageous for expressions of opinions— however misguided— in a classroom discussion that a student can be essentially kicked out of his educational program," he said.

Oyama said his statements were made "in an academic, intellectual setting," according to the ruling.

When his certification was denied, Oyama proposed the College of Education refund all tuition payments in exchange for his forfeiting all credits and grades and he would not become a classroom teacher. Officials rejected the offer and advised him of his right to appeal. A grievance committee concluded that he shouldn't be allowed to be a student teacher, but it also found the university failed to notify Oyama in a timely manner about its "dispositional concerns."

The dean of students proposed reimbursing Oyama for certain expenses if he released all his claims. Oyama rejected the offer and filed a lawsuit alleging First Amendment violations.

The university didn't immediately comment on the federal appeals court ruling.

Oyama, a graduate of prestigious Honolulu prep school Iolani, wanted to help fill Hawaii's shortage of public school teachers, especially in science in math, Seitz said. Now, he's working in his father's electronics business, Seitz said.

Seitz said he will ask for a new hearing before the full 9th Circuit and will take the case to the U.S. Supreme Court if necessary.

The national nonprofit Student Press Law Center, which aims to protect freedom of the press for student journalists, and the Philadelphia-based Foundation for Individual Rights in Education filed what's known as a friend of the court brief supporting Oyama.

"I think the 9th Circuit opinion opens the door to a broad range of speech restrictions at public universities," said Eugene Volokh, an attorney representing the organizations.