我有以下JSF 2.1登录表单,在Glassfish 3.1中运行
以及支持bean.
public String login() throws IOException, LoginException {
log.debug("Trying to login with username " + username);
HttpSession session = getRequest().getSession(true);
try {
getRequest().login(username, password);
// if OK, add Roles
????????
...................
} catch (ServletException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
log.debug("USER principal === " + getRequest().getUserPrincipal());
return "home";
}
问题是,如何在成功登录后以编程方式将角色添加到UserPrincipal?
更新1:我试图通过使用以下代码获取主题但主题== null.
Subject thisSubject = Subject.getSubject(AccessController
.getContext());
谢谢,
科恩