을 유지하지 않습니다상태 저장 EJB 내 로그인 정보를 유지하기 위해 나는 상태 EJB를 사용하고 속성 값
@Named
@RequestScoped
public class LoginController {
@Inject private SecurityService securityService;
private String username;
private String password;
private Negozio negozio;
public void login() throws IOException {
FacesContext context = FacesContext.getCurrentInstance();
ExternalContext externalContext = context.getExternalContext();
HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
try {
if (request.getUserPrincipal() != null) {
request.logout();
}
request.login(username, password);
securityService.setNegozioCorrente(negozio);
if (!securityService.authenticate()) {
throw new ServletException("Utente non abilitato.");
}
externalContext.redirect("/pippo/");
} catch (ServletException e) {
e.printStackTrace();
context.addMessage(null, new FacesMessage("Accesso Negato"));
}
}
public void logout() throws IOException {
//...
}
public String getLoggedUsername() {
Utente utenteCorrente = securityService.getUtenteCorrente();
String fullName = "";
if (utenteCorrente!=null) {
fullName = utenteCorrente.getNomeCompleto();
} else {
System.out.println("Utente NULLO");
}
return fullName;
}
//...
}
내 사용자가 실제로 내가 원하는 방식으로 로그인 할 수 있습니다 (프로그램 보안 내 도메인에서 일부 추가).
이미 내가 모든 페이지에 오신 것을 환영합니다! 당신은 #{loginController.loggedUsername}
로 로그인 "헤더에 표시 할. 로그인 할 때 내가 가진 문제는 다음 페이지에 있습니다.
은 내가 점점 계속securityService.getUtenteCorrente()
줍니다.
SecurityService EJB는! 내가이 상태 유지 EJB에 대해 뭔가 오해하고, 또는 난 그냥 예상대로 일이 뭔가를 생략 여부를 알고 싶어요.
내 목표를 무 상태 세션 빈처럼 동작 단지 "ses 사용자 상태를 유지하기위한 "sion-wide"빈. EJB가 필요하거나 SessionScoped JSF ManagedBean을 사용할 수 있습니까?
관련 항목/dupe : http://stackoverflow.com/questions/8887140/jsf-request-scoped-bean-keeps-recreating-new-stateful-session-beans-on-every-req/ – BalusC