Ejemplo n.º 1
0
  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);
  }
Ejemplo n.º 2
0
  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);
  }