1 Reply Latest reply: May 3, 2012 7:25 AM by elazhadi RSS

Listen to Seam 3 Security Events

elazhadi Newbie

Hello everyone,

      

               I have enterprise application that uses seam security 3 and I want to listen the event of authentication (e.g. UserAuthenticatedEvent or LoggedInEvent) I tried with this code but it does not work:


package ma.salamgaz.gwic.security;

 

 

import javax.enterprise.context.ApplicationScoped;

import javax.enterprise.event.Observes;

 

 

import org.jboss.seam.international.status.Messages;

import org.jboss.seam.security.Identity;

import org.jboss.seam.security.events.LoggedInEvent;

import org.jboss.seam.security.events.UserAuthenticatedEvent;

import org.jboss.solder.core.Requires;

 

 

public @ApplicationScoped

@Requires("org.jboss.seam.international.status.Messages")

class SecurityEventListener {

 

 

    public void userAuthenticated(@Observes UserAuthenticatedEvent event, Messages messages, Identity identity) {

                    System.out.println("User authenticated: " + identity.getUser().getId());

    }

 

 

    public void userLoggedIn(@Observes LoggedInEvent event, Messages messages, Identity identity) {

                    System.out.println("User authenticated: " + identity.getUser().getId());

    }

}

 

Please give me feedback on this problem