【发布时间】:2012-02-14 21:31:48
【问题描述】:
我在码头配置 BASIC-auth 时遇到问题 这是我的 web.xml
<security-constraint>
<web-resource-collection>
<web-resource-name>resources</web-resource-name>
<url-pattern>/resources/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>user</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>MyRealm</realm-name>
</login-config>
<security-role>
<role-name>user</role-name>
</security-role>
这是我尝试添加 LoginService 的 java 代码
HashLoginService myrealm = new HashLoginService("MyRealm");
myrealm.setConfig("src/main/resources/jetty-realm.properties");
root.getSecurityHandler().setLoginService(myrealm);
我的 jetty-realm.properties 文件有以下用户
user: Lag976JGQdeosfQM,user
我可以建立连接,但我无法进行身份验证,而且我在这个问题上卡了很长时间,所以帮助我的人可以获得免费的数字啤酒! ;)
【问题讨论】:
标签: authentication jetty