private CallbackHandler createClientCallbackHandler(
      final String[] mechanisms,
      final X509KeyManager keyManager,
      final X509TrustManager trustManager)
      throws Exception {
    final AuthenticationContext context =
        AuthenticationContext.empty()
            .with(
                MatchRule.ALL,
                AuthenticationConfiguration.EMPTY
                    .useKeyManagerCredential(keyManager)
                    .useTrustManager(trustManager)
                    .allowSaslMechanisms(mechanisms));

    return ClientUtils.getCallbackHandler(new URI("remote://localhost"), context);
  }
  @Before
  public void testStart() throws IOException, URISyntaxException, InterruptedException {
    System.gc();
    System.runFinalization();
    Logger.getLogger("TEST").infof("Running test %s", name.getMethodName());
    final FutureResult<Channel> passer = new FutureResult<Channel>();
    serviceRegistration =
        endpoint.registerService(
            "org.jboss.test",
            new OpenListener() {
              public void channelOpened(final Channel channel) {
                passer.setResult(channel);
              }

              public void registrationTerminated() {}
            },
            OptionMap.EMPTY);
    IoFuture<Connection> futureConnection =
        AuthenticationContext.empty()
            .with(
                MatchRule.ALL,
                AuthenticationConfiguration.EMPTY
                    .useName("bob")
                    .usePassword("pass")
                    .allowSaslMechanisms("SCRAM-SHA-256"))
            .run(
                new PrivilegedAction<IoFuture<Connection>>() {
                  public IoFuture<Connection> run() {
                    try {
                      return endpoint.connect(new URI("remote://localhost:30123"), OptionMap.EMPTY);
                    } catch (IOException | URISyntaxException e) {
                      throw new RuntimeException(e);
                    }
                  }
                });
    connection = futureConnection.get();
    IoFuture<Channel> futureChannel = connection.openChannel("org.jboss.test", OptionMap.EMPTY);
    clientChannel = futureChannel.get();
    serverChannel = passer.getIoFuture().get();
    assertNotNull(serverChannel);
  }
  private CallbackHandler createClientCallbackHandler(
      final String[] mechanisms,
      final File keyStore,
      final String keyStoreAlias,
      final char[] keyStorePassword,
      final X509TrustManager trustManager)
      throws Exception {
    final AuthenticationContext context =
        AuthenticationContext.empty()
            .with(
                MatchRule.ALL,
                AuthenticationConfiguration.EMPTY
                    .useKeyStoreCredential(
                        loadKeyStore(keyStore),
                        keyStoreAlias,
                        new KeyStore.PasswordProtection(keyStorePassword))
                    .useTrustManager(trustManager)
                    .allowSaslMechanisms(mechanisms));

    return ClientUtils.getCallbackHandler(new URI("remote://localhost"), context);
  }