Я создал EJB 3 и развернут на wildflyWildFly 8.x, вызов удаленного EJB 3 с JAAS
@Stateless
@Remote(ICoreParameterService.class)
@RolesAllowed("$APP_USER$")
@SecurityDomain("AppJaasRealm")
public class CoreParameterService extends BaseService implements ICoreParameterService{
some public functions;
} Все работает прекрасно, когда EJB и веб-развертывания на одном сервере. Теперь я хочу, чтобы вызвать EJB из развернув веб-приложения на котом или вызова EJB из приложения свинг Ниже мой клиент, который отлично работает, если я удалить @RolesAllowed, @SecureDomain из EJB
public class TestStatelessSessionBeans {
public static void main(String arg[]){
try {
final Properties clientConfigProps = new Properties();
clientConfigProps.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
clientConfigProps.put("remote.connection.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS","false");
clientConfigProps.put("remote.connection.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT","false");
clientConfigProps.put("remote.connections", "default");
clientConfigProps.put("remote.connection.default.host", "localhost");
clientConfigProps.put("remote.connection.default.port", "8080");
clientConfigProps.put("remote.connection.default.protocol", "http-remoting");
clientConfigProps.put("remote.connection.default.username", "admin"); // JAAS user
clientConfigProps.put("remote.connection.default.password", "sohail"); // JAAS password ; the encryption of pwd is 36+e2V2o0eKO3DOMG2YHI4Qd6NWL1wpd4S0z3sTuo90=
final EJBClientConfiguration ejbClientConfiguration = new PropertiesBasedEJBClientConfiguration(clientConfigProps);
final ContextSelector<EJBClientContext> ejbClientContextSelector = new ConfigBasedEJBClientContextSelector(ejbClientConfiguration);
EJBClientContext.setSelector(ejbClientContextSelector);
final Properties jndiProperties = new Properties();
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
Context context = new InitialContext(jndiProperties);
String lookUpName ="java:global/fortune-ear/fortune-service/CoreParameterService!com.autosoft.fortune.interfaces.ICoreParameterService";
lookUpName ="ejb:fortune-ear/fortune-service/CoreParameterService!com.autosoft.fortune.interfaces.ICoreParameterService";
ICoreParameterService service = (ICoreParameterService)context.lookup(lookUpName);
List<ApplicationParameterHeaderDTO> list = service.getApplicationParameterHeaderList("200000");
System.out.println(list);
System.out.println ("Object Saved..!!");
} catch (Exception e) {
e.printStackTrace();
}
}
}
в противном случае я получаю ошибку JBAS013323: Invalid Пользователь
Мой Защитный код домена в standalone.xml как ниже
<security-domain name="AppJaasRealm" cache-type="default">
<authentication>
<login-module code="Database" flag="required">
<module-option name="dsJndiName" value="java:/jdbc/fortuneDataSource"/>
<module-option name="principalsQuery" value="select vUser_Password from userinformation where vLogin_ID= ?"/>
<module-option name="rolesQuery" value="select '$APP_USER$', 'Roles' from userinformation where vLogin_ID= ?"/>
<module-option name="hashAlgorithm" value="SHA-256"/>
<module-option name="hashEncoding" value="Base64"/>
</login-module>
</authentication>
</security-domain>
Что решение, чтобы избавиться от "JBAS013323: Invalid User" ошибки и ссылаться Rmote EJB Succ essfully. Я видел тонны сообщения, но не смог найти подходящее решение для вызова моего EJB с удаленного компьютера. Я попытался поместить все возможные записи в свойства jndi и свойства клиента, но не успел.
вы решить эту проблему? – likeachamp
Нет :(он находится на удержании, если вы можете поделиться решением? –
Я только что опубликовал решение, которое решает мою проблему. Надеюсь, это поможет и вашему, – likeachamp