我已成功設置JBoss安全域,並且可以使用BASIC身份驗證(如web.xml中定義的)進行身份驗證。這一切運作良好。但是我不知道如何使用http request.login方法。在JBoss/JAAS中使用HTTP Request.login
下面的安全域(的jboss-web.xml)中工作的基本身份驗證:
<jboss-web>
<context-root>/myapp</context-root>
<security-domain>java:/jaas/myapp-realm</security-domain>
</jboss-web>
但是當我使用request.login如下:
public void login() {
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
try {
request.login(username, password);
}
catch (ServletException ex) {
java.util.logging.Logger.getLogger(UserLogin.class.getName()).log(Level.SEVERE, null, ex);
}
}
我得到下面的異常:
javax.servlet.ServletException: Failed to authenticate a principal
我知道用戶名/密碼是好的(使用BASIC auth可以正常工作)。我有TRACE級別的日誌記錄,它看起來並不像它甚至試圖進行身份驗證。我錯過了什麼?
請參閱http://java-web-development.blogspot.com/2011/07/jee-6-security-part-two-implementation.html如果您需要有關我的設置/配置的更多詳細信息。我正在使用JBoss 6.