Authentication 为嵌入式jetty添加安全性
我在jetty中配置基本身份验证时遇到问题 这是我的web.xmlAuthentication 为嵌入式jetty添加安全性,authentication,jetty,Authentication,Jetty,我在jetty中配置基本身份验证时遇到问题 这是我的web.xml <security-constraint> <web-resource-collection> <web-resource-name>resources</web-resource-name> <url-pattern>/resources/*</url-pattern> </web-resource-c
<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>
我的jetty-realm.properties文件具有以下用户
user: Lag976JGQdeosfQM,user
我可以建立连接,但我不能进行身份验证,而且我已经在这上面呆了很长一段时间了,所以无论谁帮我得到的都是免费的数字啤酒 好吧,我发现了我没有做的事, 您必须先启动LoginService才能使用它,因此我将java代码更改为
HashLoginService myrealm = new HashLoginService("MyRealm");
myrealm.setConfig("src/main/resources/jetty-realm.properties");
myrealm.start();
root.getSecurityHandler().setLoginService(myrealm);
好吧,我发现了我没有做的事, 您必须先启动LoginService才能使用它,因此我将java代码更改为
HashLoginService myrealm = new HashLoginService("MyRealm");
myrealm.setConfig("src/main/resources/jetty-realm.properties");
myrealm.start();
root.getSecurityHandler().setLoginService(myrealm);
什么是根参数?我应该把它放在contextInitialized中吗?根参数是什么?我应该把这个放在contextInitialized里面吗?