Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1B5B8109E7 for ; Tue, 16 Dec 2014 20:35:46 +0000 (UTC) Received: (qmail 723 invoked by uid 500); 16 Dec 2014 20:35:46 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 612 invoked by uid 500); 16 Dec 2014 20:35:46 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 594 invoked by uid 99); 16 Dec 2014 20:35:45 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Dec 2014 20:35:45 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 9FF86A2D680; Tue, 16 Dec 2014 20:35:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: elserj@apache.org To: commits@accumulo.apache.org Date: Tue, 16 Dec 2014 20:35:46 -0000 Message-Id: <639435200e6b4003848f0330e910af51@git.apache.org> In-Reply-To: <89899753c9164c1a8eb0abe17eb00f65@git.apache.org> References: <89899753c9164c1a8eb0abe17eb00f65@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/3] accumulo git commit: ACCUMULO-3424 Remove requirement for properties on provided token. ACCUMULO-3424 Remove requirement for properties on provided token. Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/27d4ee21 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/27d4ee21 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/27d4ee21 Branch: refs/heads/master Commit: 27d4ee212984015acc53c4514bb053d3482240de Parents: 86f7c1b Author: Josh Elser Authored: Tue Dec 16 15:26:59 2014 -0500 Committer: Josh Elser Committed: Tue Dec 16 15:28:06 2014 -0500 ---------------------------------------------------------------------- .../java/org/apache/accumulo/core/util/shell/Shell.java | 12 +++++------- .../accumulo/core/util/shell/ShellConfigTest.java | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/27d4ee21/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java b/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java index b187a76..a7ab8db 100644 --- a/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java +++ b/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java @@ -286,8 +286,7 @@ public class Shell extends ShellOptions { // process default parameters if unspecified try { - boolean hasToken = (token != null); - boolean hasTokenOptions = !loginOptions.isEmpty(); + final boolean hasToken = (token != null); if (hasToken && password != null) { throw new ParameterException("Can not supply '--pass' option with '--tokenClass' option"); @@ -300,16 +299,15 @@ public class Shell extends ShellOptions { } }); - // Need either both a token and options, or neither, but not just one. - if (hasToken != hasTokenOptions) { - throw new ParameterException("Must supply either both or neither of '--tokenClass' and '--tokenProperty'"); - } else if (hasToken) { // implied hasTokenOptions + if (hasToken) { // implied hasTokenOptions // Fully qualified name so we don't shadow java.util.Properties org.apache.accumulo.core.client.security.tokens.AuthenticationToken.Properties props; // and line wrap it because the package name is so long props = new org.apache.accumulo.core.client.security.tokens.AuthenticationToken.Properties(); - props.putAllStrings(loginOptions); + if (!loginOptions.isEmpty()) { + props.putAllStrings(loginOptions); + } token.init(props); } else { // Read password if the user explicitly asked for it, or didn't specify anything at all http://git-wip-us.apache.org/repos/asf/accumulo/blob/27d4ee21/core/src/test/java/org/apache/accumulo/core/util/shell/ShellConfigTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/accumulo/core/util/shell/ShellConfigTest.java b/core/src/test/java/org/apache/accumulo/core/util/shell/ShellConfigTest.java index 43d2e12..6b9ff14 100644 --- a/core/src/test/java/org/apache/accumulo/core/util/shell/ShellConfigTest.java +++ b/core/src/test/java/org/apache/accumulo/core/util/shell/ShellConfigTest.java @@ -72,9 +72,9 @@ public class ShellConfigTest { } @Test - public void testToken() { + public void testTokenWithoutOptions() { assertTrue(shell.config("--fake", "-tc", PasswordToken.class.getCanonicalName())); - assertTrue(output.get().contains(ParameterException.class.getCanonicalName())); + assertFalse(output.get().contains(ParameterException.class.getCanonicalName())); } @Test