I use picketlink to authenticate a user in a project. I also created @produces annotated method, so I could introduce the authenticated user to other places. Now I use envers, and in addition to the default information, I would like to save the user who performed the action, but I cannot enter it into the envers receiver. It is always zero. How can I make this injection or get this information?
Manufacturer Class:
@SessionScoped public class Resources implements Serializable { private static final long serialVersionUID = 1L; @EJB private AuthenticationManagerBean authenticator; @Inject private Identity credentials; @CurrentUser private AuthenticatedUser currentUser; @Produces @CurrentUser @SessionScoped private AuthenticatedUser createAuthenticatedUser() { AuthenticatedUser user = new AuthenticatedUser(); org.picketlink.idm.model.basic.User loggedInUser = (org.picketlink.idm.model.basic.User) credentials.getAccount(); User pu = authenticator.getUserRoles(loggedInUser.getLoginName()); if (pu != null) { user.setUser(pu.getName()); for (Role role : pu.getRoles()) { user.getRoles().add(role.getName()); } } return user; } @Produces public Logger produceLog(InjectionPoint injectionPoint) { return LoggerFactory.getLogger(injectionPoint.getMember().getDeclaringClass().getName()); }
and receiver envers:
public class AuditListener implements RevisionListener, Serializable { private static final long serialVersionUID = 1L; @Inject @CurrentUser private AuthenticatedUser identity;
source share