Take the lane if it's not safe to share the lane. If it's obvious they need to slow down, they will. Hugging the white line isn't safe, regardless of what you're riding.
I doubt it was illegal for a car to pass you. Most (maybe all) states allow cars to pass bicycles in the presence of a double yellow line. However, they must do so safely. It sounds like the driver you encountered wasn't being safe.