@Override public ConnectionOptions<T> as(CharSequence principal, AuthenticationToken token) { if (token.isDestroyed()) { throw new IllegalArgumentException("AuthenticationToken has been destroyed"); } setProperty(ClientProperty.AUTH_PRINCIPAL, principal.toString()); ClientProperty.setAuthenticationToken(properties, token); this.token = token; return this; }
protected ClientContext getContextForPeer(AccumuloConfiguration localConf, ReplicationTarget target, String principal, AuthenticationToken token) { requireNonNull(localConf); requireNonNull(target); requireNonNull(principal); requireNonNull(token); Properties properties = new Properties(); properties.setProperty(ClientProperty.INSTANCE_NAME.getKey(), instanceName); properties.setProperty(ClientProperty.INSTANCE_ZOOKEEPERS.getKey(), zookeepers); properties.setProperty(ClientProperty.AUTH_PRINCIPAL.getKey(), principal); ClientProperty.setAuthenticationToken(properties, token); return new ClientContext(ClientInfo.from(properties, token), localConf); }
@Override public Properties getProperties() { Properties properties = ClientConfConverter.toProperties(getSiteConfiguration()); properties.setProperty(ClientProperty.INSTANCE_ZOOKEEPERS.getKey(), getZooKeepers()); properties.setProperty(ClientProperty.INSTANCE_ZOOKEEPERS_TIMEOUT.getKey(), Integer.toString(getZooKeepersSessionTimeOut())); properties.setProperty(ClientProperty.INSTANCE_NAME.getKey(), getInstanceName()); ClientProperty.setAuthenticationToken(properties, getAuthenticationToken()); properties.setProperty(ClientProperty.AUTH_PRINCIPAL.getKey(), getPrincipal()); return properties; }
/** * Sets the connector information needed to communicate with Accumulo in this job. * * <p> * <b>WARNING:</b> The serialized token is stored in the configuration and shared with all * MapReduce tasks. It is BASE64 encoded to provide a charset safe conversion to a string, and is * not intended to be secure. * * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param conf * the Hadoop configuration object to configure * @param principal * a valid Accumulo user name * @param token * the user's password * @since 1.6.0 */ public static void setConnectorInfo(Class<?> implementingClass, Configuration conf, String principal, AuthenticationToken token) { checkArgument(principal != null, "principal is null"); checkArgument(token != null, "token is null"); Properties props = getClientProperties(implementingClass, conf); props.setProperty(ClientProperty.AUTH_PRINCIPAL.getKey(), principal); ClientProperty.setAuthenticationToken(props, token); setClientProperties(implementingClass, conf, props); conf.setBoolean(enumToConfKey(implementingClass, ConnectorInfo.IS_CONFIGURED), true); }