Flickr/Anthony Starks A federal judge in Brooklyn has ruled that the government can't force Apple to help break an iPhone's passcode security.

No, it's not the San Bernardino shooting case, a similar situation where the FBI is seeking to compel Apple to provide custom software to help it access data on a criminal's iPhone.

Instead, the device in question belongs to Jun Feng, a meth dealer. The government attempted to use the All Writs Act to compel Apple to help it access data on Feng's phone last year, in a preview of the controversy that would explode around San Bernardino shooter Syed Farook's iPhone.

Law enforcement found an iPhone 5S during a search of Feng's house. Feng claimed to have forgotten his passcode, and the US Drug Enforcement Administration enlisted the Federal Bureau of Investigation to help it crack what was on the phone.

Federal Magistrate Judge James Orenstein, who was overseeing the order, questioned whether the All Writs Act was sufficient legal footing, and publicly asked Apple whether it had any objections.

Apple lawyers argued in October that what the government was asking was for the power to force it to break the security on its devices.

"We're being forced to become an agent of law enforcement," an Apple lawyer said in court.

A senior Apple executive speaking on the condition of anonymity told reporters that the New York case is similar to the San Bernadino case and Monday's ruling should have a "persuasive effect" going forward.

During a court hearing, the government argued that Apple had similarly bypassed the lock screen on similar iPhones 70 times before. Feng's phone was running iOS 7, an older operating system that doesn't encrypt its data by default.

Even after Feng pleaded guilty, the government tried to compel Apple to provide technical assistance.

On Monday, Orenstein ruled in Apple's favor. From the ruling:

I conclude that under the circumstances of this case, 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....

As explained below, after reviewing the facts in the record and the parties' arguments, I conclude that none of those factors justifies imposing on Apple the obligation to assist the government's investigation against its will. I therefore deny the motion.

Here's the whole ruling: