The classificational scheme "White; black or African American; American Indian and Alaska Native; Asian; and Native Hawaiian or Pacific Islander" was instituted
on May 12, 1977 through Office of Management and Budget Directive 15, which articulates "standard classifications for record keeping, collection, and presentation of data on race and ethnicity in Federal program administrative reporting and statistical activities". In the case of Mostafa Hefny, his classification as white would be a consequence of being from North Africa (Egypt), and the fact that "white" is defined as "A person having origins in any of the original peoples of Europe, North Africa, or the Middle East". A possible point of contention is that he is not from North Africa: the directive does not say where North Africa (as opposed to unmodified Africa) is. Discussion was published in the Federal Register, August 28, 1995, about these standards, and to make a really long story short, there's a problem, and no solution. The October 30, 1997 decision states the current law. This is what you should consult for the current situation: a propos the case of Nubians, the conflict still remains regarding the definition of "white" as "A person having origins in any of the original peoples of Europe, the Middle East, or North Africa", and "black" as "person having origins in any of the black racial groups of Africa" (Nubians fall into both categories: a black racial group of Northern Africa).
In non-immigration cases, racial and ethnic data are based on self-reporting. There is no strict rule, but "self-identification is the preferred means of obtaining information about an individual's race and ethnicity" (not possible in some instances, such as birth and death records). The set of categories which the census makes available is somewhat changeable. They currently report that they comply with the 1997 standards, but this report indicates that they had intended to drop "some other race" for 2010, but did not because of a Congressional mandate.
The government does not "recognize" individuals racially, instead they "report" them in a particular manner, so that counts can be made for whatever purposes (usually Civil Rights Act compliance). The rules apply to new and revised records, and not to existing records. One would have to look at the record of Hefny's suit, but it is likely that lack of standing and failure to state a legal claim figured prominently in the dismissal, if the case was dismissed.