gpt4 book ai didi

java - Jersey Logging 过滤器为 POST 吃掉 UserPrincipal

转载 作者:行者123 更新时间:2023-11-28 23:49:54 27 4
gpt4 key购买 nike

我为 Jersey 创建了一个 LoggingFilter,并在 web.xml 中正确配置了它。一切正常。当我执行“GET”时,我得到 userPrincipal (request.getUserPrincipal()) 但对于 POST,它返回 null。我已经在 Websphere 上用 java 1.4 编写了几个 REST 服务,并且总是可以访问 userPrincipal,但是在 Tomcat/1.6 上我得到了上面的内容。我正在使用基本身份验证。 Jersey 是这样做的吗?还是 Tomcat?

<security-constraint>
<web-resource-collection>
<web-resource-name>Lookup Resources</web-resource-name>
<description>A set of secured resources.</description>
<url-pattern>/rest/lookup/*</url-pattern>
<http-method>GET</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>DataServ_Lookup</role-name>
<role-name>DataServ_Admin</role-name>
</auth-constraint>
<!-- Comment this out for Dev. It is a MUST for Prod...
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>-->

</security-constraint>

最佳答案

您为什么要创建自己的 LoggingFilter?你知道 Jersey 包括一个开箱即用的吗?您的过滤器是否以任何方式修改请求?尝试将 HttpServletRequest 注入(inject)您的资源并获取主要形式 - 查看它是否已设置。如果没有,请查看您的请求是否真的包含基本身份验证 header 。

关于java - Jersey Logging 过滤器为 POST 吃掉 UserPrincipal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10250719/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com