【发布时间】:2019-01-24 21:33:27
【问题描述】:
这可能是“XY 问题”问题的一个实例;如果是,请随时纠正我的假设来回答。
更新:在某一时刻,我曾尝试通过执行loginRequest.login(username, password); 来使用HttpServletRequest,但这无法编译,产生关于在HttpServletRequest 中找不到login(String, String) 的编译错误,所以我放弃了这个角度.但是,我刚刚找到了一个article which suggests that this is the correct change to make,所以我又回到了那条路上。
有人告诉我,我可能正在使用旧版本的课程。我的编译时类路径中可能有旧的HttpServletRequest。我现在正在调查。
从 Tomcat(在 JBoss 5 中)切换到 Undertow(在 JBoss 7 中)后,我们的用户身份验证页面已损坏。
我们有一个 HttpServlet,它曾经在 JBoss 5 的 Tomcat Web 服务器中运行。因此,它使用 Tomcat 的 WebAuthentication,如下所示:
import org.jboss.web.tomcat.security.login.WebAuthentication;
import java.io.IOException;
import javax.servlet.http.*;
// ... import etc.
public class MyHttpServlet extends HttpServlet
{
private void loginCase( HttpServletRequest loginRequest,
HttpServletResponse loginResponse ) throws ServletException, IOException, RemoteException
{
String username;
String password;
// ... other stuff
// Authenticate with the web tier. This invokes the MyLoginModule,
// which uses the user database tables to authenticate and establish
// the user's role(s). This servlet does role checking, but this step
// is necessary to get the user's credentials into the container, which
// secures remote EJBs. If this is not done, the servlets and JSPs will
// not be able to properly access secured EJBs.
WebAuthentication webAuth = new WebAuthentication();
boolean loginResult = webAuth.login(username, password);
// ...
}
}
使用WebAuthentication 之前的评论,关于使用Web 层进行身份验证的评论,不是我添加的。那是在原始代码中,看起来它解释了为什么选择WebAuthentication 作为身份验证机制。
我的理解是 Undertow/JBoss7 不再有可用的 WebAuthentication 类。
在运行时,当用户提交他们的姓名/密码条目时,会有一个ClassNotFoundException 和消息org.jboss.web.tomcat.security.login.WebAuthentication from [module "deployment.myproject.ear.viewers.war" from Service Module Loader]
现在我们无法再访问WebAuthentication(我什至将包含必要类的 Tomcat 中的 jar 文件复制到我的 .ear 文件的 lib/ 目录中,但 Undertow 似乎没有意识到这一点,我得到了不同的错误) ,我正在寻找替代品。
我的理解是,我只需要让用户通过 Web 层进行身份验证,本质上是 WebAuthentication.login 的替代品。 WebAuthentication 的唯一用途是上面代码示例中提到的两行。
我可以用什么替换 WebAuthentication 来完成这项工作?
显然,一个简单的类替换会很棒,但如果它必须比这更复杂,那么只要我们可以让它工作就可以了。
【问题讨论】: