is it possible create a Behaviour (or something like this) that every time an user log in to alfresco (with username e password) i will execute some java code? for example reading a specific space with an action? if yes how can i do this?
You would need to develop an enhancement, I don't think its there out of the box.
Yes its possible to develop your own "bahaviours" and "policies." As and when I've added a new policy done this I take a look at the existing ones and copy the patterns.
One approach would be to decorate the AuthenticationService.authenticate method.