Skip to content

Instantly share code, notes, and snippets.

@dilnei
Created August 8, 2014 18:44
Show Gist options
  • Select an option

  • Save dilnei/dbcb69e64c6bf5a42b9c to your computer and use it in GitHub Desktop.

Select an option

Save dilnei/dbcb69e64c6bf5a42b9c to your computer and use it in GitHub Desktop.
Responsável por pegar o usuário do JAAS.
package br.com.app.model.entity.listener;
import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.ejb.LocalBean;
import javax.ejb.SessionContext;
import javax.ejb.Stateless;
/**
* Responsável por pegar o usuário do JAAS.
*
* @author Dilnei Cunha
*/
@Stateless
@LocalBean
@PermitAll
public class CurrentUserBean {
@Resource
private SessionContext context;
public String getCurrentUser() {
return context.getCallerPrincipal().getName();
}
public SessionContext setCurrentUser(SessionContext context) {
return context;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment