HTTP 身份验证解码的开源 Java 服务器端实现
我需要在 servlet 应用程序中执行 HTTP 身份验证逻辑,而不是将此任务委托给容器。
具体来说,我需要一种方法来获取包含 HTTP 身份验证标头的 HttpServletRequest 标头,并将它们解码为表示所提供凭据的数据结构,然后应用程序可以处理该数据结构。应该支持基本身份验证和摘要身份验证。
我可以用手写这个,这不会太麻烦,RFC 都有详细的文档记录,但我很想使用现成的库来为我做这件事。
我的第一个想法是 Spring Security,但据我所知,这个任务委托给了容器(我对此有点不清楚,这是一个复杂的代码库)。
有人知道其他人吗?
I have a requirement to perform HTTP authentication logic within a servlet application, rather than delegating this task to the container.
Specifically, I need a way of taking the headers of an HttpServletRequest
which contains HTTP auth headers, and having them decoded into a data structure representing the supplied credentials, which the application can then process. Both basic and digest auth should be supported.
I could write this by hand, it wouldn't be too much of a chore, the RFCs are all well documented, but I'd quite like to use an off-the shelf library to do it for me.
My first thought was Spring Security, but from what I can tell this delegates this task to the container (I'm a bit unclear on that, it's a complicated code base).
Anyone know of any others?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是我的解码器:
Here is my decoder:
我不知道有什么框架,但除非您使用 BASIC 身份验证,否则您可能无法获取用户的密码。
如果您使用 BASIC 身份验证,则对
Authentication
标头进行Base64Decode
非常简单。I don't know of a framework off hand, but unless you're using BASIC authentication, you might not be able to get the password for the user.
If you are using BASIC authentication, it's pretty trivial to
Base64Decode
theAuthentication
header.