A named bean, listProjects, requires authentication which is provided by the container. I want to get the username from the named loginMBean and use it in the listProjects bean.
I have injected the authentication bean into listProjects, but when I access the username, it it null even though the user has authenticated.
@Named("loginMBean")
@SessionScoped
@PermitAll
public class LoginMBean implements Serializable {
private String username;
public String getUsername() {
return username;
}
@Named
@SessionScoped
@RolesAllowed({"Users"})
public class ListProjectsMBean implements Serializable {
@Inject
private LoginMBean wLoginMBean;
public void getList(ActionEvent actionEvent) {
String testUserName = wLoginMBean.getUsername();
l
}
wildfly 8.2 weld 2.2 java 1.7