private String getString(ClientProperty property) { return property.getValue(properties); }
public boolean getBoolean(Properties properties) { String value = getValue(properties); if (value.isEmpty()) { return false; } return Boolean.valueOf(value); }
public Integer getInteger(Properties properties) { String value = getValue(properties); if (value.isEmpty()) { return null; } return Integer.parseInt(value); }
protected void updateFromConfiguration(Properties properties) { // Get the quality of protection to use final String qopValue = ClientProperty.SASL_QOP.getValue(properties); this.qop = QualityOfProtection.get(qopValue); // Add in the SASL properties to a map so we don't have to repeatedly construct this map this.saslProperties.put(Sasl.QOP, this.qop.getQuality()); // The primary from the KRB principal on each server (e.g. primary/instance@realm) this.kerberosServerPrimary = ClientProperty.SASL_KERBEROS_SERVER_PRIMARY.getValue(properties); }
@Override public int getZooKeepersSessionTimeOut() { return (int) ConfigurationTypeHelper .getTimeInMillis(ClientProperty.INSTANCE_ZOOKEEPERS_TIMEOUT.getValue(properties)); }
public String getPrincipal() { return ClientProperty.AUTH_PRINCIPAL.getValue(getClientProperties()); }
/** * Enable tracing by setting up SpanReceivers for the current process. If host name is null, it * will be determined. If service name is null, the simple name of the class will be used. * Properties required in the client configuration include * {@link org.apache.accumulo.core.conf.ClientProperty#TRACE_SPAN_RECEIVERS} and any properties * specific to the span receiver. */ public static void enable(String hostname, String service, Properties properties) { String spanReceivers = ClientProperty.TRACE_SPAN_RECEIVERS.getValue(properties); String zookeepers = ClientProperty.INSTANCE_ZOOKEEPERS.getValue(properties); long timeout = ConfigurationTypeHelper .getTimeInMillis(ClientProperty.INSTANCE_ZOOKEEPERS_TIMEOUT.getValue(properties)); String zkPath = ClientProperty.TRACE_ZOOKEEPER_PATH.getValue(properties); Map<String,String> props = ClientProperty .toMap(ClientProperty.getPrefix(properties, ClientProperty.TRACE_SPAN_RECEIVER_PREFIX)); enableTracing(hostname, service, spanReceivers, zookeepers, timeout, zkPath, props); }
public static void validateProperty(Properties properties, ClientProperty prop) { if (!properties.containsKey(prop.getKey()) || prop.getValue(properties).isEmpty()) { throw new IllegalArgumentException(prop.getKey() + " is not set"); } }
public Long getBytes(Properties properties) { String value = getValue(properties); if (value.isEmpty()) { return null; } checkState(getType() == PropertyType.BYTES, "Invalid type getting bytes. Type must be " + PropertyType.BYTES + ", not " + getType()); return ConfigurationTypeHelper.getMemoryAsBytes(value); }
public Long getTimeInMillis(Properties properties) { String value = getValue(properties); if (value.isEmpty()) { return null; } checkState(getType() == PropertyType.TIMEDURATION, "Invalid type getting time. Type must be " + PropertyType.TIMEDURATION + ", not " + getType()); return ConfigurationTypeHelper.getTimeInMillis(value); }
@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "code runs in same security context as user who providing the token file") public static AuthenticationToken getAuthenticationToken(Properties properties) { String authType = ClientProperty.AUTH_TYPE.getValue(properties); String token = ClientProperty.AUTH_TOKEN.getValue(properties); switch (authType) { case "password": return new PasswordToken(token); case "PasswordToken": return decodeToken(PasswordToken.class.getName(), token); case "kerberos": try { String principal = ClientProperty.AUTH_PRINCIPAL.getValue(properties); return new KerberosToken(principal, new File(token)); } catch (IOException e) { throw new IllegalArgumentException(e); } case "KerberosToken": return decodeToken(KerberosToken.class.getName(), token); case "CredentialProviderToken": return decodeToken(CredentialProviderToken.class.getName(), token); case "DelegationToken": return decodeToken(DelegationToken.class.getName(), token); default: return decodeToken(authType, token); } }
public BatchWriterConfig getBatchWriterConfig() { ensureOpen(); if (batchWriterConfig == null) { Properties props = info.getProperties(); batchWriterConfig = new BatchWriterConfig(); Long maxMemory = ClientProperty.BATCH_WRITER_MEMORY_MAX.getBytes(props); if (maxMemory != null) { batchWriterConfig.setMaxMemory(maxMemory); } Long maxLatency = ClientProperty.BATCH_WRITER_LATENCY_MAX.getTimeInMillis(props); if (maxLatency != null) { batchWriterConfig.setMaxLatency(maxLatency, TimeUnit.SECONDS); } Long timeout = ClientProperty.BATCH_WRITER_TIMEOUT_MAX.getTimeInMillis(props); if (timeout != null) { batchWriterConfig.setTimeout(timeout, TimeUnit.SECONDS); } String durability = ClientProperty.BATCH_WRITER_DURABILITY.getValue(props); if (!durability.isEmpty()) { batchWriterConfig.setDurability(Durability.valueOf(durability.toUpperCase())); } } return batchWriterConfig; }
AuthenticationToken token = null; if (password == null && clientProperties.containsKey(ClientProperty.AUTH_TOKEN.getKey()) && principal.equals(ClientProperty.AUTH_PRINCIPAL.getValue(clientProperties))) { token = ClientProperty.getAuthenticationToken(clientProperties);
String principal = ClientProperty.AUTH_PRINCIPAL.getValue(props);
Properties props = InputConfigurator.getClientProperties(callingClass, conf); try (AccumuloClient c = Accumulo.newClient().from(props).build()) { String principal = ClientProperty.AUTH_PRINCIPAL.getValue(props); config.setScanAuths(c.securityOperations().getUserAuthorizations(principal));