use of org.jboss.as.protocol.ProtocolConnectionConfiguration in project wildfly-core by wildfly.
the class RemoteDomainConnection method openConnection.
/**
* Connect and register at the remote domain controller.
*
* @return connection the established connection
* @throws IOException
*/
protected Connection openConnection() throws IOException {
// Perhaps this can just be done once?
CallbackHandler callbackHandler = null;
SSLContext sslContext = null;
final ProtocolConnectionConfiguration config = ProtocolConnectionConfiguration.copy(configuration);
// TODO this needs cleaning up.
config.setCallbackHandler(callbackHandler);
config.setSslContext(sslContext);
config.setUri(uri);
AuthenticationContext authenticationContext = this.authenticationContext != null ? this.authenticationContext : AuthenticationContext.captureCurrent();
// Connect
try {
return authenticationContext.run((PrivilegedExceptionAction<Connection>) () -> ProtocolConnectionUtils.connectSync(config));
} catch (PrivilegedActionException e) {
if (e.getCause() instanceof IOException) {
throw (IOException) e.getCause();
}
throw new IOException(e);
}
}
use of org.jboss.as.protocol.ProtocolConnectionConfiguration in project wildfly-core by wildfly.
the class HostControllerConnection method asyncReconnect.
/**
* This continuously tries to reconnect in a separate thread and will only stop if the connection was established
* successfully or the server gets shutdown. If there is currently a reconnect task active the connection paramaters
* and callback will get updated.
*
* @param reconnectUri the updated connection uri
* @param authKey the updated authentication key
* @param callback the current callback
*/
synchronized void asyncReconnect(final URI reconnectUri, String authKey, final ReconnectCallback callback) {
if (getState() != State.OPEN) {
return;
}
// Update the configuration with the new credentials
final ProtocolConnectionConfiguration config = ProtocolConnectionConfiguration.copy(configuration);
config.setCallbackHandler(createClientCallbackHandler(userName, authKey));
config.setUri(reconnectUri);
this.configuration = config;
final ReconnectRunner reconnectTask = this.reconnectRunner;
if (reconnectTask == null) {
final ReconnectRunner task = new ReconnectRunner();
task.callback = callback;
task.future = executorService.submit(task);
} else {
reconnectTask.callback = callback;
}
}
use of org.jboss.as.protocol.ProtocolConnectionConfiguration in project wildfly-core by wildfly.
the class TestControllerUtils method create.
static TestControllerUtils create(URI uri, CallbackHandler callbackHandler) throws IOException {
final Endpoint endpoint = Endpoint.getCurrent();
final ProtocolConnectionConfiguration configuration = ProtocolConnectionConfiguration.create(endpoint, uri);
configuration.setCallbackHandler(callbackHandler);
return new TestControllerUtils(endpoint, configuration, createDefaultExecutor());
}
use of org.jboss.as.protocol.ProtocolConnectionConfiguration in project wildfly-core by wildfly.
the class RemotingModelControllerClient method getOrCreateChannel.
protected Channel getOrCreateChannel() throws IOException {
synchronized (closeable) {
if (closeable.closed) {
throw ControllerClientLogger.ROOT_LOGGER.objectIsClosed(ModelControllerClient.class.getSimpleName());
}
if (closeable.strategy == null) {
try {
closeable.endpoint = Endpoint.builder().setEndpointName("management-client").build();
final ProtocolConnectionConfiguration configuration = ProtocolConfigurationFactory.create(closeable.clientConfiguration, closeable.endpoint);
closeable.strategy = ManagementClientChannelStrategy.create(configuration, closeable.channelAssociation, closeable.clientConfiguration.getCallbackHandler(), closeable.clientConfiguration.getSaslOptions(), closeable.clientConfiguration.getSSLContext(), new CloseHandler<Channel>() {
@Override
public void handleClose(final Channel closed, final IOException exception) {
closeable.channelAssociation.handleChannelClosed(closed, exception);
}
});
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return closeable.strategy.getChannel();
}
}
use of org.jboss.as.protocol.ProtocolConnectionConfiguration in project wildfly-core by wildfly.
the class ConnectSyncUnitTestCase method testTimeoutFailure.
@Test
public void testTimeoutFailure() throws IOException {
ProtocolConnectionConfiguration configuration = getConfiguration(IoFuture.Status.WAITING, false, true);
try {
ProtocolConnectionUtils.connectSync(configuration);
fail();
} catch (ConnectException expected) {
TestTimeoutHandler handler = (TestTimeoutHandler) configuration.getTimeoutHandler();
assertEquals(handler.getFailure(), expected.getCause());
assertTrue(expected.getMessage().contains("WFLYPRT0053"));
}
}
Aggregations