My civil rights?

Hi Sir, Recently, I was harassed and beaten up by a person who claims to be a police officer and who has connections with the local police. I was at my rented apartment with my girlfriend. This person came to our house started questioning me regarding the house rent agreement and when i provided the document he said that whrn the apartment has been rented under my name the how is the girl staying with me. I was also beaten up after they found some personal stuff which he found out after he searched my house along with a police constable for no reason. Then this person took me and my partner to nearest beat marshal's chowki and started harassing us. Finally it all ended when the agent through whom I rented this apartment came into picture and the guy who claimed to be a cbi officer asked for a bribe of Rs 15000 from the agent. Now, what I dont understand is, where was I wrong? Whatever relationship i have with the girl and what we did was inside my house. We never ever created a scene or created any problem in the society. Is this act by the police justified? I was traumatised by this so called moral polices' actions.