@Override public void doBootstrap(TransportClient client, Channel channel) { if (!conf.encryptionEnabled()) { LOG.debug("AES encryption disabled, using old auth protocol."); doSaslAuth(client, channel); return; } try { doSparkAuth(client, channel); } catch (GeneralSecurityException | IOException e) { throw Throwables.propagate(e); } catch (RuntimeException e) { // There isn't a good exception that can be caught here to know whether it's really // OK to switch back to SASL (because the server doesn't speak the new protocol). So // try it anyway, and in the worst case things will fail again. if (conf.saslFallback()) { LOG.warn("New auth protocol failed, trying SASL.", e); doSaslAuth(client, channel); } else { throw e; } } }
@Override public void init(String appId) { this.appId = appId; TransportContext context = new TransportContext(conf, new NoOpRpcHandler(), true); List<TransportClientBootstrap> bootstraps = Lists.newArrayList(); if (authEnabled) { bootstraps.add(new AuthClientBootstrap(conf, appId, secretKeyHolder)); } clientFactory = context.createClientFactory(bootstraps); }
@Override public void init(String appId) { this.appId = appId; TransportContext context = new TransportContext(conf, new NoOpRpcHandler(), true); List<TransportClientBootstrap> bootstraps = Lists.newArrayList(); if (authEnabled) { bootstraps.add(new AuthClientBootstrap(conf, appId, secretKeyHolder)); } clientFactory = context.createClientFactory(bootstraps); }
@Override public void init(String appId) { this.appId = appId; TransportContext context = new TransportContext(conf, new NoOpRpcHandler(), true); List<TransportClientBootstrap> bootstraps = Lists.newArrayList(); if (authEnabled) { bootstraps.add(new AuthClientBootstrap(conf, appId, secretKeyHolder)); } clientFactory = context.createClientFactory(bootstraps); }
@Override public void doBootstrap(TransportClient client, Channel channel) { if (!conf.encryptionEnabled()) { LOG.debug("AES encryption disabled, using old auth protocol."); doSaslAuth(client, channel); return; } try { doSparkAuth(client, channel); } catch (GeneralSecurityException | IOException e) { throw Throwables.propagate(e); } catch (RuntimeException e) { // There isn't a good exception that can be caught here to know whether it's really // OK to switch back to SASL (because the server doesn't speak the new protocol). So // try it anyway, and in the worst case things will fail again. if (conf.saslFallback()) { LOG.warn("New auth protocol failed, trying SASL.", e); doSaslAuth(client, channel); } else { throw e; } } }
void createClient(String secret, boolean enableAes) throws Exception { TransportConf clientConf = enableAes ? conf : new TransportConf("rpc", MapConfigProvider.EMPTY); List<TransportClientBootstrap> bootstraps = Arrays.asList( new AuthClientBootstrap(clientConf, appId, createKeyHolder(secret))); this.client = ctx.createClientFactory(bootstraps) .createClient(TestUtils.getLocalHost(), server.getPort()); }
@Override public void doBootstrap(TransportClient client, Channel channel) { if (!conf.encryptionEnabled()) { LOG.debug("AES encryption disabled, using old auth protocol."); doSaslAuth(client, channel); return; } try { doSparkAuth(client, channel); } catch (GeneralSecurityException | IOException e) { throw Throwables.propagate(e); } catch (RuntimeException e) { // There isn't a good exception that can be caught here to know whether it's really // OK to switch back to SASL (because the server doesn't speak the new protocol). So // try it anyway, and in the worst case things will fail again. if (conf.saslFallback()) { LOG.warn("New auth protocol failed, trying SASL.", e); doSaslAuth(client, channel); } else { throw e; } } }
void createClient(String secret, boolean enableAes) throws Exception { TransportConf clientConf = enableAes ? conf : new TransportConf("rpc", MapConfigProvider.EMPTY); List<TransportClientBootstrap> bootstraps = Arrays.asList( new AuthClientBootstrap(clientConf, appId, createKeyHolder(secret))); this.client = ctx.createClientFactory(bootstraps) .createClient(TestUtils.getLocalHost(), server.getPort()); }