He's an authority figure to you. You're not entitled to being subservient and obedient to him, considering he's your friend. It wasn't alright by any stretch of the imagination for him to be given the option to "square away" the bad feelings he had by lashing out at you.