(a) If no sufficient legal cause of detention is shown, the plaintiff shall be discharged.
(b) The party detained shall be remanded to custody:

(1) If it appears the party is detained by virtue of process issued by a court or judge of the United States, in a case where such court or judge has exclusive jurisdiction;
(2) Where the time during which such party may be legally detained has not expired; or
(3) In every case in which the detention is authorized by law.