It's a civil action. Someone filed a FOIA request to see the unredacted Mueller Report, and when Barr refused, they sued.
The issue is that it is believed the redactions were not proper, and the only way the judge can rule is to see what was redacted. It boils down to whether or not AG Barr is credible, and given that his 4 page summary of the MR was a misrepresentation to ostensibly protect Trump, the judge believed there is a likelihood redactions could likely be done in the same fashion, not to protect bona fide state secrets, but to protect Trump.
That would be a violation of Barr's oath of office.
Judges have a lot of leeway to subpoena stuff in order to get to the truth so they can make a ruling.
And yes, Judges do get to see classified stuff in order to make rulings
How judges handle classified documents.