我使用Wildfly版本10。
我已经设置了我的使用jdbc领域来验证用户身份的安全域,这是命令:
/subsystem=elytron/jdbc-realm=app-security-realm:add(principal-query=[{sql="SELECT password FROM USERS WHERE username = ?", data-source="mysqlDS", clear-password-mapper={password-index=1}},{sql="SELECT GROUPNAME FROM GROUPS WHERE username = ?", data-source="mysqlDS", attribute-mapping=[{index=1, to=roles}]}])
/subsystem=elytron/simple-role-decoder=from-roles-attribute:add(attribute=roles)
/subsystem=elytron/security-domain=app-security-domain:add(default-realm=app-security-realm, realms=[{realm=app-security-realm, role-decoder=from-roles-attribute}], permission-mapper=default-permission-mapper)
/subsystem=elytron/http-authentication-factory=app-security-http-auth:add(http-server-mechanism-factory=global,security-domain=app-security-domain,mechanism-configurations=[{mechanism-name=BASIC,mechanism-realm-configurations=[{realm-name=RealmUsersRoles}]}])
/subsystem=undertow/application-security-domain=app-security-domain:add(http-authentication-factory=app-security-http-auth)
jboss-web.xml:
<security-domain>app-security-domain</security-domain>
web.xml:
...
<security-constraint>
<display-name>AccountingConstraint</display-name>
<web-resource-collection>
<web-resource-name>accounting</web-resource-name>
<url-pattern>/views/user/*</url-pattern>
<url-pattern>/views/accounting/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>accounting</role-name>
</auth-constraint>
</security-constraint>
...
基本身份验证适用于视图,这意味着我在wildfly中的配置适用。
但是当我尝试保护我的ejb时:
@Stateless
@SecurityDomain("app-security-domain")
public class ContractsEJB implements Contracts {
@Inject
private ExternalContext externalContext;
@Override
public boolean isAdmin() {
return externalContext.isUserInRole("admin");
}
}
然后我收到以下错误:
wildfly_1 | 18:15:44,644 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 2) WFLYCTL0013: Operation ("full-replace-deployment") failed - address: ([]) - failure description: {
wildfly_1 | "WFLYCTL0412: Required services that are not installed:" => ["jboss.security.security-domain.app-security-domain"],
wildfly_1 | "WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.deployment.unit.\"Spellchecker-1.0.war\".component.ContractsEJB.CREATE is missing [jboss.security.security-domain.app-security-domain]"]
wildfly_1 | }
我是JAVA EE和Wildfly的新手,如果这是一个愚蠢的问题,我非常抱歉:)谢谢您的帮助。
Solution,由Martin Choma在一个类似的问题上。
component.MemberRegistration.CREATE(ejb?)使用旧版安全域