Answer:
1. You have given the officer consent
2. The officer has probable cause to believe there is evidence of a crime in your vehicle
3. The officer reasonably believes a search is necessary for their own protection (a hidden weapon, for example); and
4. You have been arrested and the search is related to that arrest (such as a search for illegal drugs).