如果我在wildfly中使用默认安全域设置,我可以成功调用远程EJB。我访问此安全域根本不检查任何用户凭据。在实现或使用检查数据库中的用户名和密码的安全域后,我遇到了以下异常。
我无法弄清楚我错过了什么。我希望有人能指出我正确的方向。
例外:
#lang send-dot
(define o
(new (class object% (super-new)
(define/public (f x) x))))
(o.f "hellooo")
的JBoss-ejb3.xml:
Exception in thread "main" javax.ejb.EJBAccessException: WFLYSEC0027: Invalid User
at org.jboss.as.ejb3.security.SecurityContextInterceptor$1.run(SecurityContextInterceptor.java:69)
at org.jboss.as.ejb3.security.SecurityContextInterceptor$1.run(SecurityContextInterceptor.java:49)
at org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:97)
...
standalone.xml
<jboss:jboss
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:jboss="http://www.jboss.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:s="urn:security:1.1"
version="3.1" impl-version="2.0">
<assembly-descriptor>
<s:security>
<!-- Even wildcard * is supported -->
<ejb-name>*</ejb-name>
<!-- Name of the security domain which is configured in the EJB3 subsystem -->
<s:security-domain>ejb-database-policy</s:security-domain>
</s:security>
</assembly-descriptor>
TestRemote.java
<security-domain name="ejb-database-policy" cache-type="default">
<authentication>
<login-module code="Database" flag="required">
<module-option name="dsJndiName" value="java:/jdbc/mysqlds"/>
<module-option name="principalsQuery" value="SELECT user_password FROM app_user WHERE username=?"/>
<module-option name="rolesQuery" value="SELECT role, 'Roles' FROM user_role WHERE username=?"/>
<module-option name="hashAlgorithm" value="SHA-256"/>
<module-option name="hashEncoding" value="base64"/>
<module-option name="unauthenticatedIdentity" value="guest"/>
</login-module>
</authentication>
</security-domain>
谢谢, 钟
答案 0 :(得分:1)
问题解决了。
这是我做的额外步骤/设置。
1)在standalone.xml中,我将ApplicationRealm身份验证更改为JAAS。
<security-realm name="ApplicationRealm">
<authentication>
<jaas name="ejb-database-policy"/>
</authentication>
<authorization>
<properties path="application-roles.properties" relative-to="jboss.server.config.dir"/>
</authorization>
</security-realm>
2)在TestRemote.java中,我添加了prop.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
多数民众赞成。
谢谢,贝尔