The White House was forced to reinstate Jim Acosta’s press pass after a court ruled the revocation violated the CNN reporter’s Fifth Amendment rights, prompting President Donald Trump to vow to create new “rules and regulations” for press.

Federal Judge Timothy Kelly ruled in favor of CNN in the company’s suit against the president and several of his top aides and advisers, criticizing the fact that the decision to ban Acosta was “shrouded in mystery” and that the administration’s claim that the reporter put his hands on an intern was “partly based on evidence of questionable accuracy.”

Kelly also criticized CNN’s case, saying that although he did not personally agree with the case law that governs his decision, he had to follow it.

“I’ve read the case closely,” he said. “Whether it’s what I agree with, that’s a different story. But I must apply precedent as I see it.”

SLIDESHOW: DONALD TRUMP’S 30 CRAZIEST TWEETS

“[The ruling] strikes me as an extremely savvy and wise resolution of this case,” said Jeffrey Toobin, CNN’s chief legal analyst.

During the hearing, CNN argued that the administration’s decision to revoke Acosta’s “hard pass” violated both the reporter’s First Amendment press rights and his Fifth Amendment right to due process.

Judge Kelly ruled only on the latter argument, granting Acosta a temporary restraining order on the grounds that the Trump administration had not given ample justification or due process to Acosta before making its decision.

Despite this, Press Secretary Sarah Huckabee-Sanders said in a statement, “Today, the court made clear that there is no absolute First Amendment right to access the White House.”

“We will also further develop rules and processes to ensure fair and orderly press conferences in the future. There must be decorum at the White House,” she added.

The ruling sent a message to the White House that it would have to implement new statutes of conduct for reporters if it wanted to revoke the attendance rights of members of the press to White House briefings.

By creating new rules for behavior and conduct during briefings, the Trump administration would be able to justify revoking press passes if reporters speak out of turn or take hostile tones.

In an interview with Fox on Friday, President Trump said, “What they said, though, is that we have to create rules and regulations for conduct, et cetera. We’re going to write them up. It’s not a big deal. If he misbehaves, we’ll throw him out or we’ll stop the news conference.”

“If they don’t listen to the rules and regulations, we’ll end up back in court and we’ll win. But more importantly, we’ll just leave. And then you won’t be very happy. Because we do get good ratings,” said Trump.

“I think, you know, we’re ready to litigate as long as we have to to protect these First Amendment rights, to ask the court to declare rules of the road going forward,” CNN lawyer Ted Boutrous said.