They can do it
737i:
Yes, According to the Chicago Convention (Article 16) specifies that any state authority have the right to search the aircraft, and apply the laws accordingly, be it aviation or local laws, it doesn't specify. It only applies to civil Aircraft, Not state Aircraft.
I understand how uncomfortable the situation can be, but is better just to fully comply than try to object or fight authority, the simply can stop your flight until compliance. good thing it was in Sweden, there are other European and first world American countries than can react third world style if you refuse.