Author: vines
Date: Wed Mar 6 23:17:15 2013
New Revision: 1453614
URL: http://svn.apache.org/r1453614
Log:
ACCUMULO-1155 - CLI properties!
Modified:
accumulo/trunk/ (props changed)
accumulo/trunk/core/ (props changed)
accumulo/trunk/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
Propchange: accumulo/trunk/
------------------------------------------------------------------------------
Merged /accumulo/branches/1.5:r1453603-1453612
Propchange: accumulo/trunk/core/
------------------------------------------------------------------------------
Merged /accumulo/branches/1.5/core:r1453603-1453612
Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java?rev=1453614&r1=1453613&r2=1453614&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java Wed Mar
6 23:17:15 2013
@@ -18,7 +18,10 @@ package org.apache.accumulo.core.cli;
import java.nio.charset.Charset;
import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
import java.util.Map.Entry;
+import java.util.Properties;
import java.util.TreeMap;
import java.util.UUID;
@@ -46,6 +49,7 @@ import org.apache.hadoop.mapreduce.Job;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
+import com.beust.jcommander.DynamicParameter;
import com.beust.jcommander.IStringConverter;
import com.beust.jcommander.Parameter;
@@ -108,13 +112,33 @@ public class ClientOpts extends Help {
@Parameter(names = "--password", converter = PasswordConverter.class, description = "Enter
the connection password", password = true)
public Password securePassword = null;
+ @DynamicParameter(names = "-l",
+ description = "login properties in the format key=value. Reuse -l for each property
(prompt for properties if this option is missing")
+ public Map<String,String> loginProps = new LinkedHashMap<String,String>();
+
public AuthenticationToken getToken() {
- if (securePassword == null) {
- if (password == null)
- return null;
+ if (!loginProps.isEmpty()) {
+ Properties props = new Properties();
+ for (Entry<String,String> loginOption : loginProps.entrySet())
+ props.put(loginOption.getKey(), loginOption.getValue());
+
+ try {
+ System.out.println(props);
+ return getInstance().getAuthenticator().login(props);
+ } catch (AccumuloSecurityException e) {
+ throw new RuntimeException(e);
+ } catch (AccumuloException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ if (securePassword != null)
+ return new PasswordToken(securePassword.value);
+
+ if (password != null)
return new PasswordToken(password.value);
- }
- return new PasswordToken(securePassword.value);
+
+ return null;
}
@Parameter(names = {"-z", "--keepers"}, description = "Comma separated list of zookeeper
hosts (host:port,host:port)")
|