好的,所以我一直在Tomcat上运行带有基本身份验证的Java/Jersey Web服务,该方法工作得很好。我在项目的web.xml文件中设置了权限,而用户在服务器上的tomcat-users.xml中设置了权限。效果很好。
问题是,现在我必须将这个项目转移到WebSphere,它远没有实现基本身份验证那么简单。
我已经看到了这个问题:Websphere 6.1 and BASIC Authentication,并像建议的那样查看了this pdf的第7章,但我似乎找不到正确的设置(我没有像大多数方法使用的那样标记为“启用全局安全性”的选项),并且正在尝试来运行我的项目,而pdf则是特定于项目的。
因此,要清楚地问我一个问题,在WebSphere 6.1上启用基本身份验证的最简单方法是什么?
最佳答案
在下面写下所有这些内容之后,我记得我已经在这里为自己写过一篇博客:
WebSphere 6.1 and Application Authentication
据我了解,您已经正确设置了web.xml:
<security-role>
<role-name>myrole</role-name>
</security-role>
<security-constraint>
<web-resource-collection>
<web-resource-name>mySec</web-resource-name>
<url-pattern>/yourUrl</url-pattern>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
<http-method>HEAD</http-method>
<http-method>TRACE</http-method>
<http-method>OPTIONS</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>myrole</role-name>
</auth-constraint>
<user-data-constraint>
<description>SSL or MSSL not required</description>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>my login</realm-name>
</login-config>
这是如果您使用的是管理控制台,但您没有声明自己不是,那么请转到控制台:
http://localhost:9060/ibm/console
然后登录(如果您具有管理安全性设置)
那你去
然后,您将打开应用程序安全性。现在,您需要将应用程序的用户映射到Websphere中的用户。
到这里
如果您的web.xml设置正确,您只会看到此链接
必须启用管理安全性(Websphere本身的安全性)才能使其正常工作。
WebSphere可能很复杂,但是功能强大且功能强大。