The judge rejected the argument that the government doesn't have the authority to enforce such a ban.