Read the Penal Code and CCP. You will see that it was a lawful order and within his authority.
I’m not going to read the whole code. You have the burden to show me that it is in the code. You find it and show me. You claimed it was a legal order, if it is, then it should be easy to find.