The legal validity of this and the previous executive order is the following (I'm quoting from the Washington Post):
'In Title 8, Section 1182 of the U.S. Code, the president has authority to use a proclamation to suspend the entry of [i]“any aliens or of any class of aliens into the United States [who] would be detrimental to the interests of the United States,”
for however long he deems necessary. This provision was included in the Immigration and Nationality Act of 1952.section 301 of title 3, United States Code.'.
Why anybody would object to this [iin principle] I cannot understand. For instance, if there were large numbers of Germans seeking residence in the 1930s you might very well chosen to discriminate between those Germans who were fleeing persecution (the Jews) and those Germans who were Nazis or Nazi sympathisers. In this context who could reasonably have claimed that this discrimination was unconstitutional? I would argue that such discrimination would have met the standards of both compassion and prudence.
I don't think that Section 1182 is mentioned in the original order suspending the EO but I may be wrong. The article I've quoted (appearing under the heading which I can't help maliciously renaming to "Faked Checker") attempts to deal with this argument. Here's the full article:
https://www.washingtonpost.com/news/fact-checker/wp/2016/06/15/donald-trumps-almost-true-claim-that-the-president-has-power-to-ban-any-class-of-persons/?utm_term=.1a976e957859