The Supreme Court case Korematsu vs. United States determined that the internment of Japanese-American citizens during World War II was indeed constitutional (legal). The judges voted 6-3 in favor of the American government.
In this case, the majority opinion essentially argued that protecting American society against espionage( aka spying by the Japanese) outweighed the rights of Japanese-American citizens. Ultimately, it came down to the fact that the nations security was at risk and this was more important than the individual liberties of Japanese-American citizens.