use of org.wildfly.security.auth.client.InvalidAuthenticationConfigurationException in project wildfly by wildfly.
the class UndertowSSLv2HelloTestCase method testOneWayElytronClientServerSupportsSSLv2Hello.
/**
* One way SSL - RESTEasy client sends SSLv2Hello message and server supports the protocol.
* Handshake should succeed.
*/
@Test
public void testOneWayElytronClientServerSupportsSSLv2Hello() throws Exception {
configureSSLContext(SSLV2HELLO_CONTEXT_ONE_WAY);
AuthenticationContext context = doPrivileged((PrivilegedAction<AuthenticationContext>) () -> {
try {
URL config = getClass().getResource("wildfly-config-one-way-sslv2hello.xml");
return ElytronXmlParser.parseAuthenticationClientConfiguration(config.toURI()).create();
} catch (Throwable t) {
throw new InvalidAuthenticationConfigurationException(t);
}
});
context.run(() -> {
ClientBuilder clientBuilder = ClientBuilder.newBuilder().hostnameVerifier((s, sslSession) -> true);
Client client = clientBuilder.build();
Response response = client.target(String.valueOf(securedRootUrl)).request().get();
Assert.assertEquals(200, response.getStatus());
});
restoreConfiguration();
}
use of org.wildfly.security.auth.client.InvalidAuthenticationConfigurationException in project wildfly by wildfly.
the class UndertowSSLv2HelloTestCase method testTwoWayElytronServerClientDefaultConfig.
/**
* Two Way SSL - Client and Server don't support SSLv2Hello as it has not been explicitly configured.
* They each have their default configuration. Handshake should succeed.
*/
@Test
public void testTwoWayElytronServerClientDefaultConfig() throws Exception {
configureSSLContext(DEFAULT_CONTEXT);
AuthenticationContext context = doPrivileged((PrivilegedAction<AuthenticationContext>) () -> {
try {
URL config = getClass().getResource("wildfly-config-no-sslv2hello.xml");
return ElytronXmlParser.parseAuthenticationClientConfiguration(config.toURI()).create();
} catch (Throwable t) {
throw new InvalidAuthenticationConfigurationException(t);
}
});
context.run(() -> {
ClientBuilder clientBuilder = ClientBuilder.newBuilder().hostnameVerifier((s, sslSession) -> true);
Client client = clientBuilder.build();
Response response = client.target(String.valueOf(securedRootUrl)).request().get();
Assert.assertEquals(200, response.getStatus());
});
restoreConfiguration();
}
use of org.wildfly.security.auth.client.InvalidAuthenticationConfigurationException in project wildfly by wildfly.
the class UndertowSSLv2HelloTestCase method testTwoWayElytronServerNoSSLv2HelloSupport.
/**
* Two way SSL - Server does not support SSLv2Hello, but client sends SSLv2Hello message.
* Handshake should fail.
*/
@Test(expected = ProcessingException.class)
public void testTwoWayElytronServerNoSSLv2HelloSupport() throws Exception {
configureSSLContext(DEFAULT_CONTEXT);
AuthenticationContext context = doPrivileged((PrivilegedAction<AuthenticationContext>) () -> {
try {
URL config = getClass().getResource("wildfly-config-sslv2hello.xml");
return ElytronXmlParser.parseAuthenticationClientConfiguration(config.toURI()).create();
} catch (Throwable t) {
throw new InvalidAuthenticationConfigurationException(t);
}
});
context.run(() -> {
ClientBuilder clientBuilder = ClientBuilder.newBuilder().hostnameVerifier((s, sslSession) -> true);
Client client = clientBuilder.build();
Response response = client.target(String.valueOf(securedRootUrl)).request().get();
Assert.assertEquals(200, response.getStatus());
});
restoreConfiguration();
}
use of org.wildfly.security.auth.client.InvalidAuthenticationConfigurationException in project wildfly by wildfly.
the class UndertowTwoWaySslNeedClientAuthTestCase method testClientConfigProviderSSLContextForCorrectHostWillWork.
/**
* Test that RESTEasy client does choose SSLContext from Elytron client based on destination of the request.
* In this case the truststore is set for correct endpoint/server and so SSL handshake will succeed.
*/
@Test
public void testClientConfigProviderSSLContextForCorrectHostWillWork() {
AuthenticationContext context = doPrivileged((PrivilegedAction<AuthenticationContext>) () -> {
try {
URL config = getClass().getResource("wildfly-config-correct-truststore-correct-host.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());
});
}
use of org.wildfly.security.auth.client.InvalidAuthenticationConfigurationException 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