如何知道资源是否在 jsr-196 auth 模块中受到保护?
我编写了一个自定义 JSR-196 模块,它结合了多种机制来保护资源。
如果提供身份验证,它会很好地工作。
现在,如果访问受保护的资源并且未提供身份验证,我想将用户重定向到某个登录页面。
我如何知道资源受到保护?我不想重定向不受保护的图像或登录页面本身。我使用 web.xml 来允许不受限制的访问。对于这些页面,发送 AuthStatus.SUCCESS 似乎是显示它们的唯一方法。我宁愿认为我需要发送 AuthStatus.SEND_CONTINUE。我需要一种方法来判断是否需要限制这些访问。
我正在使用 Glassfish 3.1。
I wrote a custom JSR-196 module, which combines multiple mechanisms to protect resources.
It works quite well if authentication is provided.
Now, if a protected resource is accessed and authentication isn't provided, I'd like to redirect my user to some login page.
How can I know that a resource is protected? I don't want to redirect for unprotected images or for the login page itself. I used web.xml to allow unrestricted access to that. For those pages, sending AuthStatus.SUCCESS seems to be the only way to display them. I'd rather think I need to send AuthStatus.SEND_CONTINUE. And I'd need a way to tell if I need to restrict access on those.
I'm using Glassfish 3.1.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
似乎我以某种方式删除了 requestPolicy.isMandatory() 检查...
这就是神奇的地方,它告诉您资源是否受到保护。
我认为 requestPolicy 与 ServerAuthModule 相关联。现在,这是事实,但为受保护和不受保护的资源创建了不同的 ServerAuthModule。
Seems that I somehow removed the requestPolicy.isMandatory() check...
That's where the magic happens, it tells you if a resource is protected.
I thought requestPolicy was tied to the ServerAuthModule. Now, this is true, but a different ServerAuthModule is created for protected and unprotected resource.