When I try to set the user and credentials for the security context to invoke remote ejb calls from one server to another, the user is not set. The user is correctly authenticated for standalone remote clients.
The code snippet I tried is
public OMSCoreServicesWrapperRemote lookupConnectorFacadeRemote(String ip, String uniReqId) {
try
{ // create your authentication configuration AuthenticationConfiguration namingConfig = AuthenticationConfiguration .empty() .useName("ejbUser") .usePassword("password") .useRealm("ApplicationRealm") .setSaslMechanismSelector(SaslMechanismSelector.NONE.addMechanism("DIGEST-MD5")) .useProviders( () -> new Provider[]
);
// create your authentication context
AuthenticationContext context = AuthenticationContext.empty().with(MatchRule.ALL, namingConfig);
context.getInstanceContextManager().setThreadDefault(context);
context.getInstanceContextManager().setGlobalDefault(context);
return context.runCallable(vCallable);
} catch (Exception e)
}
Callable<OMSCoreServicesWrapperRemote> vCallable = () ->
{ String ip = "192.168.14.55"; Properties jndiProps = new Properties(); jndiProps.put(Context.SECURITY_PRINCIPAL, "ejbUser"); jndiProps.put(Context.SECURITY_CREDENTIALS, "password"); jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory"); jndiProps.put(Context.PROVIDER_URL, System.getProperty("remote+http://192.168.0.51:8181"); Context ctx = new InitialContext(jndiProps); String lookupName = ejbServiceLocatorI.getMergedEjbLookupNameMapperRemote().get(OMSCoreServicesWrapperRemote.class.getSimpleName()); return (OMSCoreServicesWrapperRemote) ctx.lookup(lookupName); };
server.log attachment contains the complete log since the server start up.
standalone-full_xml is the config file of the server
The resources I referred to solve this issue are
https://developer.jboss.org/thread/277371
https://github.com/wildfly/quickstart/tree/11.x/ejb-security-context-propagation
But the issue remains the same.