ula.uvula
ula.uvula

Reputation: 195

EAP8: create rest client with elytron client-ssl-context

EAP8: create rest client with elytron client-ssl-context

Originally I had the question to get a SSLContext from Jboss EAP. Stackoverflow question: EAP: create rest client with elytron client-ssl-context

So I use this implementation to create a REST client using SSLContext from EAP configuration, it works fine in JEE8 environment.

@ApplicationScoped
public class InitalizerOnStartup {

    private MyService myService;

    // getter

    public void onStart(@Observes @Initialized(ApplicationScoped.class) Object pointless) throws Exception {
        buildRestClient();
    }

    private void buildRestClient () throws Exception {
        final String sdName = "java:jboss/jaas/projectB-client/jsse";
        final URL endPoint = new URL("https://localhost:8443/myUrl");
        Context ctx = new InitialContext();
        JBossJSSESecurityDomain sd = (JBossJSSESecurityDomain) ctx.lookup(sdName);
        if ( sd == null )
            throw new Exception("Can't get EAP security domain - name=" + sdName);
        SSLContext sslContext = SSLContext.getInstance("TLS");
        sslContext.init(sd.getKeyManagers(), sd.getTrustManagers(), null);

        ResteasyClientBuilder builder = new ResteasyClientBuilder();
        builder.sslContext(sslContext);
        ResteasyClient client = builder.build();
        ResteasyWebTarget target = client.target(endPoint.toURI());
        myService = target.proxy(MyService.class);
    }
}

Now I migration to JEE10/Jakarta with EAP8. I moved everything to Elytron, Picketbox is gone.

I'm looking for a similar way to get KeyManager + Trustmanager from EAP8 configuration, but I can't find any working solution yet.

Any hints?

Upvotes: 0

Views: 30

Answers (0)

Related Questions