Also, more to this: why would you acting like a dick to cops. Don't people want this to go down as smoothly as possible? It seems, from reading the posts here, that you can refuse to show your ID and refuse for them to search your car; but honestly; it looks suspicious as heck or feels like you just want to be a smartass. Legal or not.
I would just hand in my id, I don't give a damn; I'm not running from the law. Cops just want to scan it to see if you have unpaid tickets, warrants, stuff like that, it's just a security check. They don't know you, they have no idea, you could be some crazy criminal on the run. It's just a technical thing they have to do when they interact with you.
That's even how they caught the Later Days Saints leader who was on the run from the FBI and was on the top 10 most wanted. Cops randomly stopped his car after his bodyguard ran a traffic light and when they checked his ID, they found out it was him. I know its an extreme case, but it's just the kind of reasons why they check for this.
Why piss people off, why act like a smartass, just hand them your damn id, be neutral and cooperative.. Why start shit?