<div dir="ltr"><div>Hello,<br></div><div><br></div><div>trying to integrate the Keycloak &quot;server&quot; into my own JAX-RS application (for the integration with the UnifiedPush Server). I started w/ a simple app.</div>
<div><br></div><div>Generally I am doing something similar to what the LiveOak folks do:</div><div>I create leverage the Admin realm, using Java APIs:</div><div><a href="https://github.com/liveoak-io/liveoak/blob/master/modules/keycloak/src/main/java/io/liveoak/keycloak/KeycloakServer.java#L72-L104">https://github.com/liveoak-io/liveoak/blob/master/modules/keycloak/src/main/java/io/liveoak/keycloak/KeycloakServer.java#L72-L104</a><br>
</div><div><br></div><div><br></div><div>Now, to get rid of the &#39;keycloak.json&#39; file for the AS7 adapter, I tried the following, inside of the constructor of my JAX-RS Application class (which extends KeycloakApplication):</div>
<div><br></div><div>....</div><div>final AdapterConfig config = new AdapterConfig();</div><div><br></div><div>config.setRealm(adminRealm.getName());</div><div>config.set......</div><div>......</div><div><br></div><div>final ObjectMapper om = new ObjectMapper();</div>
<div>String json = null;</div><div>try {</div><div>    json = om.writeValueAsString(config);</div><div>} catch (IOException e) {</div><div>    e.printStackTrace();</div><div>}</div><div><br></div><div>servletContext.setInitParameter(AdapterConstants.AUTH_DATA_PARAM_NAME, json);</div>
<div>....</div><div><br></div><div><br></div><div>However, that happens too late (a ServletContextListener is too late as well). This line of code:</div><div><a href="https://github.com/keycloak/keycloak/blob/master/integration/as7-eap6/adapter/src/main/java/org/keycloak/adapters/as7/KeycloakAuthenticatorValve.java#L75">https://github.com/keycloak/keycloak/blob/master/integration/as7-eap6/adapter/src/main/java/org/keycloak/adapters/as7/KeycloakAuthenticatorValve.java#L75</a></div>
<div><br></div><div>is invoked before the constructor of my JAX-RS Application class (which extends KeycloakApplication); same with a context listener.</div><div><br></div><div><br></div><div>I am wondering what&#39;s the best way to provide the &quot;keycloak.json&quot; content, using Java APIs ? </div>
<div><br></div><div><br></div><div>Greetings,</div><div>Matthias</div><div><br></div><div><br></div><div><br></div>-- <br>Matthias Wessendorf <br><br>blog: <a href="http://matthiaswessendorf.wordpress.com/" target="_blank">http://matthiaswessendorf.wordpress.com/</a><br>
sessions: <a href="http://www.slideshare.net/mwessendorf" target="_blank">http://www.slideshare.net/mwessendorf</a><br>twitter: <a href="http://twitter.com/mwessendorf" target="_blank">http://twitter.com/mwessendorf</a>
</div>