是否可以从 webapp 中为 javaee 安全提供自定义身份验证机制?

Is it possible to supply custom authentication mechanism to javaee security from within the webapp?

我想使用 javaee 安全性,但我需要根据外部专有身份验证机制对用户进行身份验证,该机制不同于 LDAP 和 Wildfly 附带的任何其他标准机制。特别是,我更希望身份验证由应用程序而不是容器来处理。我只遇到过PolicyConfiguration。但我认为这意味着构建一个扩展以插入底层应用程序服务器。

我想要的是让应用服务器以标准的javaee方式获取凭据,然后执行回调到应用程序中以授权它们,然后建立当前用户及其角色,这样我就可以使用使用注释的声明性安全。

这在标准方式下可行吗?或者唯一的解决方案是为应用服务器构建一个扩展模块?

一个不太优雅的解决方案是使用 HttpServlet.login 执行登录。您仍然需要配置一个领域,以确认您在方法调用中提供的用户名和密码。

另一个更复杂的解决方案是创建一个 JASPIC authentication provider. In short, you are in charge of the whole authentication process. Here is a collection of resources to get you started: Zeef