Tim Cook should be loving this decision. Marcio Jose Sanchez/AP

Apple's fight in a California federal court over the FBI's attempts to unlock an iPhone received a boost from a similar case decided on Monday in a Brooklyn courtroom.

In the more high-profile California battle, the FBI, citing a 227-year-old law called the All Writs Act (AWA), wants to force Apple to create software that would allow the FBI to access one of the San Bernardino shooter's iPhones.

Broadly, the 1789 AWA allows courts to require compliance with their orders even when not covered by existing law.

The tech giant, however, has refused, even filing a motion to reverse the court order and testifying before Congress. Some legal experts speculate that the case might go all the way to the US Supreme Court.

Now Apple has achieved a victory in a separate but similar case. On Monday, a federal judge in Brooklyn ruled that the government can't use the AWA to force Apple to assist in breaking an alleged meth dealer's iPhone passcode.

In his decision, US Magistrate Judge James Orenstein shredded the government's employment of the AWA in the case before him as well as the one involving the San Bernardino shooter's phone.

In fact, Orenstein argues that the government's most recent use of the 1789 law "goes so far as to contend that a court — without any legislative authority other than the AWA — can require Apple to create a brand new product that impairs the utility of the products it is in the business of selling."

Orenstein's decision comes as the first test of the government's legal argument for accessing devices like the iPhone, The New York Times reports. As such, and because the judge specifically addressed the AWA, an Apple senior executive said that the Brooklyn case could have a "persuasive effect" on the California judge ruling on the San Bernardino issue.

In his 50-page decision, Orenstein says that federal courts may only issue a writ, but don't have to, if the circumstances meet three requirements:

1. issuance of the writ must be 'in aid of' the issuing court's jurisdiction;

2. the type of writ requested must be 'necessary or appropriate' to provide such aid to the issuing court's jurisdiction; and

3. the issue of the writ must be 'agreeable to the usages and principles of the law.

In Orenstein's mind, the government easily meets the first two stipulations but fails on the third. Essentially, the judge rules, the government wants the AWA to give it more power than the statute actually can.

"In arguing to the contrary, the government posits a reading of the latter phrase so expansive — and in particular, in such tension with the doctrine of separation of power — as to cast doubt on the AWA's constitutionality if adopted," he writes.

Investigators examine the scene around an SUV where two suspects were shot by police following a mass shooting in San Bernardino, California, on December 4. REUTERS/Alex Gallardo

Even if the government does meet those three requirements necessary to have a court issue a writ, Orenstein writes, the deciding court must consider three more principles:

1. the closeness of the relationship between the person or entity to whom the proposed writ is directed and the matter over which the court has jurisdiction;

2. the reasonableness of the burden to be imposed on the writ's subject; and

3. the necessity of the requested writ to aid the court's jurisdiction (which does replicate the second statutory element, despite the overlapping language).

Orenstein concluded that none of them applied.

"The government has failed to establish either that the AWA permits the relief it seeks or that, even if such an order is authorized, the discretionary factors I must consider weigh in favor of granting the motion" for Apple, he writes.

In the California case, Apple's team of lawyers have argued that the company's forced compliance with an order to help the FBI unlock an iPhone would violate the First and Fifth amendments to the US Constitution.

Apple's lawyers invoke the due-process clause of the Fifth Amendment by arguing, in part, that Apple has an "extraordinarily attenuated connection to the crime," so complying with the FBI would be "highly burdensome" for the company. That logic runs parallel to the factors the court must consider when weighing the appropriateness of the AWA's application.

The ACLU, which plans to file an amicus brief in support of Apple, will also argue that the All Writs Act doesn't apply, Esha Bhandari, staff attorney on the American Civil Liberties Union's Project on Speech, Privacy, and Technology, told Business Insider.

"Even the All Writs Act hasn't been used in this way of compelling third parties to create something and thus, act as agents of law enforcement," Bhandari said.

In perhaps the most certain and heated line of his decision, Orenstein denounces how broadly the government has attempted to apply the AWA.

He writes:

It is thus clear that the government is relying on the AWA as a source of authority that is legislative in every meaningful way: something that can be cited as a basis for getting the relief it seeks in case after case without any need for adjudication of the particular circumstances of an individual case.