Search in sources :

Example 11 with InvalidAuthenticationConfigurationException

use of org.wildfly.security.auth.client.InvalidAuthenticationConfigurationException in project wildfly by wildfly.

the class UndertowTwoWaySslNeedClientAuthTestCase method testResteasyElytronClientTrustedServer.

/**
 * RESTEasy client loads truststore from Elytron client configuration. This truststore contains correct server certificate.
 */
@Test
public void testResteasyElytronClientTrustedServer() {
    AuthenticationContext context = doPrivileged((PrivilegedAction<AuthenticationContext>) () -> {
        try {
            URL config = getClass().getResource("wildfly-config-correct-truststore.xml");
            return ElytronXmlParser.parseAuthenticationClientConfiguration(config.toURI()).create();
        } catch (Throwable t) {
            throw new InvalidAuthenticationConfigurationException(t);
        }
    });
    context.run(() -> {
        ClientBuilder resteasyClientBuilder = ClientBuilder.newBuilder().hostnameVerifier((s, sslSession) -> true);
        Client client = resteasyClientBuilder.build();
        Response response = client.target(String.valueOf(securedRootUrl)).request().get();
        Assert.assertEquals(200, response.getStatus());
    });
}
Also used : Response(javax.ws.rs.core.Response) AuthenticationContext(org.wildfly.security.auth.client.AuthenticationContext) InvalidAuthenticationConfigurationException(org.wildfly.security.auth.client.InvalidAuthenticationConfigurationException) AuthenticationContextConfigurationClient(org.wildfly.security.auth.client.AuthenticationContextConfigurationClient) Client(javax.ws.rs.client.Client) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) HttpClient(org.apache.http.client.HttpClient) ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) URL(java.net.URL) ClientBuilder(javax.ws.rs.client.ClientBuilder) Test(org.junit.Test)

Aggregations

URL (java.net.URL)11 Client (javax.ws.rs.client.Client)11 ClientBuilder (javax.ws.rs.client.ClientBuilder)11 Response (javax.ws.rs.core.Response)11 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)11 ModelControllerClient (org.jboss.as.controller.client.ModelControllerClient)11 Test (org.junit.Test)11 AuthenticationContext (org.wildfly.security.auth.client.AuthenticationContext)11 InvalidAuthenticationConfigurationException (org.wildfly.security.auth.client.InvalidAuthenticationConfigurationException)11 HttpClient (org.apache.http.client.HttpClient)6 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)6 AuthenticationContextConfigurationClient (org.wildfly.security.auth.client.AuthenticationContextConfigurationClient)6 SSLContext (javax.net.ssl.SSLContext)1