If any person who is within the United States claims a right or privilege as a national of the United States and is denied such right or privilege by any department or independent agency, or official thereof, upon the ground that he is not a national of the United States, such person may institute an action under the provisions of section 2201 of title 28 against the head of such department or independent agency for a judgment declaring him to be a national of the United States, except that no such action may be instituted in any case if the issue of such person’s status as a national of the United States (1) arose by reason of, or in connection with any removal proceeding under the provisions of this chapter or any other act, or (2) is in issue in any such removal proceeding. An action under this subsection may be instituted only within five years after the final administrative denial of such right or privilege and shall be filed in the district court of the United States for the district in which such person resides or claims a residence, and jurisdiction over such officials in such cases is conferred upon those courts.
If any person who is not within the United States claims a right or privilege as a national of the United States and is denied such right or privilege by any department or independent agency, or official thereof, upon the ground that he is not a national of the United States, such person may make application to a diplomatic or consular officer of the United States in the foreign country in which he is residing for a certificate of identity for the purpose of traveling to a port of entry in the United States and applying for admission. Upon proof to the satisfaction of such diplomatic or consular officer that such application is made in good faith and has a substantial basis, he shall issue to such person a certificate of identity. From any denial of an application for such certificate the applicant shall be entitled to an appeal to the Secretary of State, who, if he approves the denial, shall state in writing his reasons for his decision. The Secretary of State shall prescribe rules and regulations for the issuance of certificates of identity as above provided. The provisions of this subsection shall be applicable only to a person who at some time prior to his application for the certificate of identity has been physically present in the United States, or to a person under sixteen years of age who was born abroad of a United States citizen parent.
A person who has been issued a certificate of identity under the provisions of subsection (b), and while in possession thereof, may apply for admission to the United States at any port of entry, and shall be subject to all the provisions of this chapter relating to the conduct of proceedings involving aliens seeking admission to the United States. A final determination by the Attorney General that any such person is not entitled to admission to the United States shall be subject to review by any court of competent jurisdiction in habeas corpus proceedings and not otherwise. Any person described in this section who is finally denied admission to the United States shall be subject to all the provisions of this chapter relating to aliens seeking admission to the United States.