java - Wildfly:服务器重启后授权失败
问题描述
我首先进行所需的设置(如下所述)。一切正常,但是当我重新启动standalone.sh
并执行 SOAP 请求时,我只会得到以下响应:
<html>
<head>
<title>Error</title>
</head>
<body>Unauthorized</body>
</html>
在终端中standalone.sh
我得到:
ERROR [org.jboss.security] (default task-1) PBOX00261: Failed to load users/passwords/roles files: java.io.IOException: PBOX00072: Properties file users.properties/defaultUsers.properties not found
我应该怎么做才能使授权工作?
设置
这就是我设置所有内容的方法:
- 我从原型运行
mvn archetype:generate
并创建项目org.wildfly.archetype:wildfly-javaee7-webapp-ear-blank-archetype
groupId:pl.edu.agh.soa
artifactId:实验室
Hello.java
我在以下位置创建了一个类lab/lab-ejb/src/main/java/pl/edu/agh/soa
:
@Stateless
@WebService
@SecurityDomain("domain1")
@DeclareRoles({"developer"})
@WebContext(
authMethod="BASIC",
transportGuarantee="NONE")
public class Hello {
private List<String> subjects = new ArrayList<>();
private String name;
private String surname;
@WebMethod
@RolesAllowed("developer")
@XmlElementWrapper(name="subjects")
@XmlElement(name="subject")
public List<String>
listSubjects(@WebParam(name="filter") String filter) {
List<String> filtered = new ArrayList<>();
for(String elem : this.subjects) {
if(elem.contains(filter)) {
filtered.add(elem);
}
}
return filtered;
}
@WebMethod
@RolesAllowed("developer")
@WebResult
public String
addSubject(@WebParam(name="subj") String subj) {
this.subjects.add(subj);
return "After add: " + this.subjects.toString();
}
@WebMethod
@RolesAllowed("developer")
@WebResult
public String
editName(String name) {
String before = this.name;
this.name = name;
return "Before: " + before;
}
@WebMethod
@RolesAllowed("developer")
@WebResult
public String
editSurname(String surname) {
String before = this.surname;
this.surname = surname;
return "Before: " + before;
}
}
- 我
user3
用 add-user.sh添加 - 使用 创建一个新的安全域
jboss-cli.sh
,我在那里粘贴:
/subsystem=security/security-domain=domain1/:add(cache-type=default)
/subsystem=security/security-domain=domain1/authentication=classic:add(login-modules=[{"code"=>"UsersRoles","flag"=>"required","module-options"=>[("usersProperties"=>"users.properties"),("rolesProperties"=>"roles.properties")]}])
- 我创建
users.properties
并roles.properties
归档lab/lab-ejb/src
解决方案
您可以尝试将roles.properties
andusers.properties
放在另一个目录中,例如:\wildfly-20.0.1.Final\standalone\configuration
或src/main/resources
推荐阅读
- ruby-on-rails - Rails 中有类似 Laravel Passport 的东西吗?
- git - 在 git 中保留或删除功能分支的常见或建议做法是什么?
- c - 在 C 程序中,带小数的值被四舍五入
- java - 如何在 Android 中使用改造在单个 POST 方法中发布文本数据、单个图像和多个图像?
- c++ - 函数指针问题
- r - 如何将粗体字体大小更改为 shinyWidgets 包的 pickerInput() 中的组标题?
- reactjs - 在 React-three-fiber 中获取对象的本地位置
- javascript - 汇总:单个 html 输出
- python-3.x - 我的 .py 可执行文件或设置文件可以在我的笔记本电脑上运行,但不能在另一个系统上运行
- java - 如何使用 hashmap 计算骰子眼频?