use of org.apache.accumulo.core.client.ClientConfiguration in project accumulo by apache.
the class ShellOptionsJC method getAuthenticationToken.
public AuthenticationToken getAuthenticationToken() throws Exception {
if (null == authenticationToken) {
final ClientConfiguration clientConf = getClientConfiguration();
// Automatically use a KerberosToken if the client conf is configured for SASL
final boolean saslEnabled = Boolean.parseBoolean(clientConf.get(ClientProperty.INSTANCE_RPC_SASL_ENABLED));
if (saslEnabled) {
authenticationToken = new KerberosToken();
}
}
return authenticationToken;
}
use of org.apache.accumulo.core.client.ClientConfiguration in project accumulo by apache.
the class ConfiguratorBaseTest method testSetZooKeeperInstance.
@Test
public void testSetZooKeeperInstance() {
Configuration conf = new Configuration();
ConfiguratorBase.setZooKeeperInstance(this.getClass(), conf, ClientConfiguration.create().withInstance("testInstanceName").withZkHosts("testZooKeepers").withSsl(true).withZkTimeout(1234));
ClientConfiguration clientConf = ClientConfiguration.deserialize(conf.get(ConfiguratorBase.enumToConfKey(this.getClass(), ConfiguratorBase.InstanceOpts.CLIENT_CONFIG)));
assertEquals("testInstanceName", clientConf.get(ClientProperty.INSTANCE_NAME));
assertEquals("testZooKeepers", clientConf.get(ClientProperty.INSTANCE_ZK_HOST));
assertEquals("true", clientConf.get(ClientProperty.INSTANCE_RPC_SSL_ENABLED));
assertEquals("1234", clientConf.get(ClientProperty.INSTANCE_ZK_TIMEOUT));
assertEquals(ZooKeeperInstance.class.getSimpleName(), conf.get(ConfiguratorBase.enumToConfKey(this.getClass(), ConfiguratorBase.InstanceOpts.TYPE)));
// We want to test that the correct parameters from the config get passed to the ZKI
// but that keeps us from being able to make assertions on a valid instance name at ZKI creation
// Instance instance = ConfiguratorBase.getInstance(this.getClass(), conf);
// assertEquals(ZooKeeperInstance.class.getName(), instance.getClass().getName());
// assertEquals("testInstanceName", ((ZooKeeperInstance) instance).getInstanceName());
// assertEquals("testZooKeepers", ((ZooKeeperInstance) instance).getZooKeepers());
// assertEquals(1234000, ((ZooKeeperInstance) instance).getZooKeepersSessionTimeOut());
}
use of org.apache.accumulo.core.client.ClientConfiguration in project accumulo by apache.
the class ThriftTransportKeyTest method testConnectionCaching.
@Test
public void testConnectionCaching() throws IOException, InterruptedException {
UserGroupInformation user1 = UserGroupInformation.createUserForTesting("user1", new String[0]);
final KerberosToken token = EasyMock.createMock(KerberosToken.class);
final ClientConfiguration clientConf = ClientConfiguration.loadDefault();
// The primary is the first component of the principal
final String primary = "accumulo";
clientConf.withSasl(true, primary);
// A first instance of the SASL cnxn params
SaslConnectionParams saslParams1 = user1.doAs(new PrivilegedExceptionAction<SaslConnectionParams>() {
@Override
public SaslConnectionParams run() throws Exception {
return new SaslConnectionParams(clientConf, token);
}
});
// A second instance of what should be the same SaslConnectionParams
SaslConnectionParams saslParams2 = user1.doAs(new PrivilegedExceptionAction<SaslConnectionParams>() {
@Override
public SaslConnectionParams run() throws Exception {
return new SaslConnectionParams(clientConf, token);
}
});
ThriftTransportKey ttk1 = new ThriftTransportKey(HostAndPort.fromParts("localhost", 9997), 1l, null, saslParams1), ttk2 = new ThriftTransportKey(HostAndPort.fromParts("localhost", 9997), 1l, null, saslParams2);
// Should equals() and hashCode() to make sure we don't throw away thrift cnxns
assertEquals(ttk1, ttk2);
assertEquals(ttk1.hashCode(), ttk2.hashCode());
}
use of org.apache.accumulo.core.client.ClientConfiguration in project accumulo by apache.
the class ClientContextTest method defaultValueForSensitiveProperty.
@Test
public void defaultValueForSensitiveProperty() {
if (!isCredentialProviderAvailable) {
return;
}
ClientConfiguration clientConf = ClientConfiguration.create();
AccumuloConfiguration accClientConf = ClientContext.convertClientConfig(clientConf);
Assert.assertEquals(Property.INSTANCE_SECRET.getDefaultValue(), accClientConf.get(Property.INSTANCE_SECRET));
}
use of org.apache.accumulo.core.client.ClientConfiguration in project accumulo by apache.
the class ClientContextTest method sensitivePropertiesIncludedInProperties.
@Test
public void sensitivePropertiesIncludedInProperties() {
if (!isCredentialProviderAvailable) {
return;
}
String absPath = getKeyStoreUrl(keystore);
ClientConfiguration clientConf = ClientConfiguration.create().with(Property.GENERAL_SECURITY_CREDENTIAL_PROVIDER_PATHS.getKey(), absPath);
AccumuloConfiguration accClientConf = ClientContext.convertClientConfig(clientConf);
Map<String, String> props = new HashMap<>();
accClientConf.getProperties(props, x -> true);
// Only sensitive properties are added
Assert.assertEquals(Property.GENERAL_RPC_TIMEOUT.getDefaultValue(), props.get(Property.GENERAL_RPC_TIMEOUT.getKey()));
// Only known properties are added
Assert.assertFalse(props.containsKey("ignored.property"));
Assert.assertEquals("mysecret", props.get(Property.INSTANCE_SECRET.getKey()));
}
Aggregations