Migrate Wildfly 10 to 12 - RMI custom login module not working
milad.jafary Jun 22, 2018 6:17 PMHi.
We are migrating from wilfly 10 to 12. In wildfly 10 we developed custom LoginModule(for making http basic authentication) which make a RMI call to a remote EJB located in another sever and remote EJB on that server find subject through making a query on database. After migrating to wildfly 12 it dose not work and throw this exception:
javax.ejb.NoSuchEJBException: EJBCLIENT000079: Unable to discover destination for request for EJB StatelessEJBLocator for "....", view is interface ..., affinity is None at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:567) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:503) at org.jboss.ejb.protocol.remote.RemotingEJBClientInterceptor.handleInvocationResult(RemotingEJBClientInterceptor.java:56) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:569) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:503) at org.jboss.ejb.client.TransactionPostDiscoveryInterceptor.handleInvocationResult(TransactionPostDiscoveryInterceptor.java:133) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:569) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:503) at org.jboss.ejb.client.DiscoveryEJBClientInterceptor.handleInvocationResult(DiscoveryEJBClientInterceptor.java:118) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:569) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:503) at org.jboss.ejb.client.NamingEJBClientInterceptor.handleInvocationResult(NamingEJBClientInterceptor.java:78) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:569) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:503) at org.jboss.ejb.client.TransactionInterceptor.handleInvocationResult(TransactionInterceptor.java:172) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:569) at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:503) at org.jboss.ejb.client.EJBClientInvocationContext.awaitResponse(EJBClientInvocationContext.java:907) at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:165) at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:100) at com.sun.proxy.$Proxy120.findSubjectBy(Unknown Source) at com.common.security.jaas.remote.CustomeRemoteLoginModule.initializeLoginRemote(CustomeRemoteLoginModule.java:85) at com.common.security.jaas.remote.CustomeRemoteLoginModule.initialize(CustomeRemoteLoginModule.java:54) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498)
The remote EJB was deployed and we can found it in log
java:global/test-ear/core/TestSecurityFacade!com.common.security.jaas.remote.RemoteAuth java:app/core/TestSecurityFacade!com.common.security.jaas.remote.RemoteAuth java:module/TestSecurityFacade!com.common.security.jaas.remote.RemoteAuth java:jboss/exported/test-ear/core/TestSecurityFacade!com.common.security.jaas.remote.RemoteAuth
The login module configuration in wildfly 12 is :
<subsystem xmlns="urn:jboss:domain:security:2.0">
<security-domain name="test-sec-domain">
<authentication>
<login-module code="com.common.security.jaas.remote.CustomeRemoteLoginModule" flag="required">
<module-option name="hashEncoding" value="base64"/>
<module-option name="hashAlgorithm" value="SHA-256"/>
<module-option name="remoteImplClassName" value="TestSecurityFacade"/>
<module-option name="ignorePasswordCase" value="true"/>
</login-module>
</authentication>
</security-domain>
</subsystem>
The code which is making JNDI lookup for find remote EJB is :
Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory"); env.put(Context.URL_PKG_PREFIXES, "org.wildfly.naming.client.NamingProvider"); try { InitialContext context = new InitialContext(env); RemoteAuth remoteAuth = ((remoteAuth) context.lookup("ejb:test-ear/core/TestSecurityFacade!com.common.security.jaas.remote.RemoteAuth")); String username = remoteAuth.findSubject("test"); } catch (NamingException e) { logger.error("Error in initialise context", e); }
Is there any idea about this problem? Is there any built-in login module for this purpose? How can I migrate this configuration to elytron?