The US president has invoked archaic immigration laws and even attacked judges who objected to his decisions.