wildflyでデフォルトのセキュリティドメインを使用している場合、リモートEJBを正常に呼び出すことができます。私はこのセキュリティドメインはユーザーの資格情報をまったくチェックしていません。データベースのユーザー名とパスワードをチェックするセキュリティドメインを実装または使用した後、以下の例外が発生します。call remote ejb returns Wildfly 9.0.1を使用している無効なユーザ
私は何が欠けているのか分かりません。私はここの誰かが正しい方向に私を向けることを願っています。
例外:
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)
...
のJBoss-ejb3.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>
standalone.xml
<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>
TestRemote.java
public class TestRemote {
public static void main(String[] args) {
new TestRemote().exec();
}
public void exec() {
try {
Hashtable prop = new Hashtable();
prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
prop.put(Context.PROVIDER_URL, "http-remoting://127.0.0.1:8080");
prop.put(Context.SECURITY_PRINCIPAL, "anonymous");
prop.put(Context.SECURITY_CREDENTIALS, "admin");
prop.put("jboss.naming.client.ejb.context", true);
Context context = new InitialContext(prop);
final String ejb = "/MyAppEar/MyAppEjb//UserBean!com.test.controller.UserBeanRemote";
UserBeanRemote bean = (UserBeanRemote)context.lookup(ejb);
List<AppUser> users = bean.getUserList(null, 0, 0);
if(users != null) {
for(AppUser user: users) {
System.out.println("UserID: " + user.getUserId() + ", username:" + user.getUsername());
}
} else {
System.out.println("User list is empty");
}
} catch(NamingException e) {
e.printStackTrace();
}
}
}
おかげで、 ベル