A federal judge has dismissed all criminal charges against former FBI Director James Comey, ruling that the prosecutor who brought the case was illegally appointed, abruptly ending one of the most politically charged cases in Washington.