use of org.wildfly.security.auth.client.AuthenticationContextConfigurationClient in project wildfly by wildfly.
the class UndertowTwoWaySslNeedClientAuthTestCase method testClientConfigProviderSSLContextIgnoredIfDifferentIsSet.
/**
* Elytron client has configured truststore that does not contain server's certificate.
* Test will pass because Elytron config is ignored since different ssl context is specified on RESTEasy client builder specifically.
*/
@Test
public void testClientConfigProviderSSLContextIgnoredIfDifferentIsSet() throws URISyntaxException, GeneralSecurityException {
AuthenticationContextConfigurationClient AUTH_CONTEXT_CLIENT = AccessController.doPrivileged((PrivilegedAction<AuthenticationContextConfigurationClient>) AuthenticationContextConfigurationClient::new);
AuthenticationContext context = doPrivileged((PrivilegedAction<AuthenticationContext>) () -> {
try {
URL config = getClass().getResource("wildfly-config-correct-truststore-missing.xml");
return ElytronXmlParser.parseAuthenticationClientConfiguration(config.toURI()).create();
} catch (Throwable t) {
throw new InvalidAuthenticationConfigurationException(t);
}
});
AuthenticationContext contextWithTruststore = 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);
}
});
SSLContext sslContext = AUTH_CONTEXT_CLIENT.getSSLContext(securedRootUrl.toURI(), contextWithTruststore);
context.run(() -> {
ClientBuilder resteasyClientBuilder = ClientBuilder.newBuilder();
resteasyClientBuilder.sslContext(sslContext).hostnameVerifier((s, sslSession) -> true);
Client client = resteasyClientBuilder.build();
Response response = client.target(String.valueOf(securedRootUrl)).request().get();
Assert.assertEquals(200, response.getStatus());
});
}
Aggregations