Is it legal?

Hello, i have a question.Few months ago i received a letter from our agency ( we are renting our flat from agency) that they will send somebody to check our boiler. Today i was in a shower, after shower i started to dress up , and heard one little knock , and then immediately somebody put a key inside the door. I thought that it was my husband, as he knocks and then comes in as well, so there i was standing in my bra and knickers when a stranger opens my door and comes in. I was in total shock, im pregnant as well(due in april), and i felt so embarrassed, he was looking at me for at least 10 sec and then went out. And said that agency send him. Now im feeling uncomfortable that somebody was seeing me almost naked. Is that legal? They really can come in when ever they want?Sorry im not sure where to post this one, but really need some advice.