You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by vi...@apache.org on 2013/01/02 21:26:35 UTC
svn commit: r1427997 - in
/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands:
CreateUserCommand.java ScanCommand.java SetAuthsCommand.java
Author: vines
Date: Wed Jan 2 20:26:34 2013
New Revision: 1427997
URL: http://svn.apache.org/viewvc?rev=1427997&view=rev
Log:
ACCUMULO-677 - cleaning up shell for these changes
Modified:
accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateUserCommand.java
accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ScanCommand.java
accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetAuthsCommand.java
Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateUserCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateUserCommand.java?rev=1427997&r1=1427996&r2=1427997&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateUserCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateUserCommand.java Wed Jan 2 20:26:34 2013
@@ -18,28 +18,16 @@ package org.apache.accumulo.core.util.sh
import java.io.IOException;
-import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.TableExistsException;
import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.core.util.shell.Shell;
import org.apache.accumulo.core.util.shell.Shell.Command;
import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
-public class CreateUserCommand extends Command {
- private Option scanOptAuths;
-
- static Authorizations parseAuthorizations(final String field) {
- if (field == null || field.isEmpty()) {
- return Constants.NO_AUTHS;
- }
- return new Authorizations(field.split(","));
- }
-
+public class CreateUserCommand extends Command {
@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, TableNotFoundException, AccumuloSecurityException,
TableExistsException, IOException {
@@ -59,10 +47,8 @@ public class CreateUserCommand extends C
if (!password.equals(passwordConfirm)) {
throw new IllegalArgumentException("Passwords do not match");
}
- final Authorizations authorizations = parseAuthorizations(cl.hasOption(scanOptAuths.getOpt()) ? cl.getOptionValue(scanOptAuths.getOpt()) : "");
shellState.getConnector().securityOperations().createUser(user, password.getBytes());
- Shell.log.debug("Created user " + user + " with" + (authorizations.isEmpty() ? " no" : "") + " initial scan authorizations"
- + (!authorizations.isEmpty() ? " " + authorizations : ""));
+ Shell.log.debug("Created user " + user);
return 0;
}
@@ -79,9 +65,6 @@ public class CreateUserCommand extends C
@Override
public Options getOptions() {
final Options o = new Options();
- scanOptAuths = new Option("s", "scan-authorizations", true, "scan authorizations");
- scanOptAuths.setArgName("comma-separated-authorizations");
- o.addOption(scanOptAuths);
return o;
}
Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ScanCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ScanCommand.java?rev=1427997&r1=1427996&r2=1427997&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ScanCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ScanCommand.java Wed Jan 2 20:26:34 2013
@@ -22,6 +22,7 @@ import java.util.List;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
+import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.IteratorSetting;
@@ -239,11 +240,18 @@ public class ScanCommand extends Command
final String user = shellState.getConnector().whoami();
Authorizations auths = shellState.getConnector().securityOperations().getUserAuthorizations(user);
if (cl.hasOption(scanOptAuths.getOpt())) {
- auths = CreateUserCommand.parseAuthorizations(cl.getOptionValue(scanOptAuths.getOpt()));
+ auths = ScanCommand.parseAuthorizations(cl.getOptionValue(scanOptAuths.getOpt()));
}
return auths;
}
+ static Authorizations parseAuthorizations(final String field) {
+ if (field == null || field.isEmpty()) {
+ return Constants.NO_AUTHS;
+ }
+ return new Authorizations(field.split(","));
+ }
+
@Override
public String description() {
return "scans the table, and displays the resulting records";
Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetAuthsCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetAuthsCommand.java?rev=1427997&r1=1427996&r2=1427997&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetAuthsCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetAuthsCommand.java Wed Jan 2 20:26:34 2013
@@ -38,7 +38,7 @@ public class SetAuthsCommand extends Com
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException {
final String user = cl.getOptionValue(userOpt.getOpt(), shellState.getConnector().whoami());
final String scanOpts = cl.hasOption(clearOptAuths.getOpt()) ? null : cl.getOptionValue(scanOptAuths.getOpt());
- shellState.getConnector().securityOperations().changeUserAuthorizations(user, CreateUserCommand.parseAuthorizations(scanOpts));
+ shellState.getConnector().securityOperations().changeUserAuthorizations(user, ScanCommand.parseAuthorizations(scanOpts));
Shell.log.debug("Changed record-level authorizations for user " + user);
return 0;
}