I think I’ve written here some topics about wildfly-config and EJB setting for client configuration. Let me go deep on this topic this time (these are the previous topics about it: here1 and here2).
Wildfly-config.xml will have its own syntax, but it is quite simple to understand, let see complete example. Basically everything must be in configuration, below authentication client, where we can defined the key stores, ssl contexts, and ssl context rules. Where the rules -> context -> key store. The default authentication rule is used and the defined at the bottom.
<?xml version="1.0" encoding="UTF-8"?>
...
<configuration>
<authentication-client xmlns="urn:elytron:1.0">
<!-- key stores-->
<key-stores>
<key-store name="qsKeyStore" type="JKS">
<file name="server.keystore"/>
<key-store-clear-password password="secret"/>
</key-store>
</key-stores>
<!-- ssl context definition -->
<ssl-contexts>
<ssl-context name="aContext">
<trust-store key-store-name="qsKeyStore"/>
<cipher-suite selector="DEFAULT"/>
<protocol names="TLSv1.2"/> <!-- tls v 1.2 -->
</ssl-context>
</ssl-contexts>
<!-- usage -->
<ssl-context-rules>
<rule use-ssl-context="aContext"/>
</ssl-context-rules>
<!-- authentication rules use teh default configuration -->
<authentication-rules>
<rule use-configuration="default" />
</authentication-rules>
<!-- Default configuration defined below \, and used above ^-->
<authentication-configurations>
<configuration name="default">
<sasl-mechanism-selector selector="#ALL" />
<set-mechanism-properties>
<property key="wildfly.sasl.local-user.quiet-auth" value="true" />
</set-mechanism-properties>
<providers>
<use-service-loader/>
</providers>
<!-- Used for EJB over HTTP, remoting invocations will use transparent auth-->
<set-user-name name="auser" />
<credentials>
<clear-password password="apassword!" />
</credentials>
</configuration>
</authentication-configurations>
</authentication-client>
</configuration>
Now, in regards to using wildfly-config.xml, we can just do the following lookup for http and for https:
<authentication-client xmlns="urn:elytron:1.0">
<!-- key stores-->
<key-stores>
<key-store name="qsKeyStore" type="JKS">
<file name="server.keystore"/>
<key-store-clear-password password="secret"/>
</key-store>
</key-stores>
<!-- ssl context definition -->
<ssl-contexts>
<ssl-context name="qsSSLContext">
<trust-store key-store-name="qsKeyStore"/>
<cipher-suite selector="DEFAULT"/>
<protocol names="TLSv1.2"/>
</ssl-context>
</ssl-contexts>
<!-- usage -->
<ssl-context-rules>
<rule use-ssl-context="qsSSLContext"/>
</ssl-context-rules>
<!-- authentication rules use teh default configuration -->
<authentication-rules>
<rule use-configuration="default" />
</authentication-rules>
And the initial context, for latest Wildfly, we can do as follows:
//Get Initial Context
public static Context getInitialContext() throws NamingException{
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
props.put(Context.PROVIDER_URL,"https://localhost:8443/wildfly-services");// <---- https:8443
final Context context = new InitialContext(props);
return context;
}
So then we have, basically, http:8080/wildfly-services or https:8443/wildfly-services