Well the cop certainly did nothing wrong by asking for the permit and ID. Cops are allowed to approach, make conversation, and fish for information. Anything you voluntarily give, whether it is an ID or a search, is on you. A lot of this could have been avoided if you just refused to give your ID over. If he made a fuss and detained you, I would have complied to his commands but made sure as many people as I could were witness to the fact that you were detained. From there, legal action could possibly be taken.
The only thing I saw that the cop did outside of the law was to say you couldn't leave after he said you weren't being detained.
Now go away or I will taunt you a second time...
And it's Killer Angel... as in the book