@VisibleForTesting public ThriftTransportKey(HostAndPort server, long timeout, ClientContext context) { requireNonNull(server, "location is null"); this.server = server; this.timeout = timeout; this.sslParams = context.getClientSslParams(); this.saslParams = context.getSaslParams(); if (saslParams != null) { // TSasl and TSSL transport factories don't play nicely together if (sslParams != null) { throw new RuntimeException("Cannot use both SSL and SASL thrift transports"); } } }
@Override public void createLocalUser(final String principal, final PasswordToken password) throws AccumuloException, AccumuloSecurityException { checkArgument(principal != null, "principal is null"); if (context.getSaslParams() == null) { checkArgument(password != null, "password is null"); } executeVoid(client -> { if (context.getSaslParams() == null) { client.createLocalUser(Tracer.traceInfo(), context.rpcCreds(), principal, ByteBuffer.wrap(password.getPassword())); } else { client.createLocalUser(Tracer.traceInfo(), context.rpcCreds(), principal, ByteBuffer.wrap(new byte[0])); } }); }
/** * Create a transport that is not pooled * * @param address * Server address to open the transport to * @param context * RPC options */ public static TTransport createTransport(HostAndPort address, ClientContext context) throws TException { return createClientTransport(address, (int) context.getClientTimeoutInMillis(), context.getClientSslParams(), context.getSaslParams()); }