You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2019/08/13 07:43:07 UTC

[GitHub] [accumulo] BukrosSzabolcs commented on a change in pull request #1322: ACCUMULO-3455: ShellOptionsJC should extend ClientOpts

BukrosSzabolcs commented on a change in pull request #1322: ACCUMULO-3455: ShellOptionsJC should extend ClientOpts
URL: https://github.com/apache/accumulo/pull/1322#discussion_r313258199
 
 

 ##########
 File path: shell/src/main/java/org/apache/accumulo/shell/ShellOptionsJC.java
 ##########
 @@ -45,84 +40,12 @@
   @Parameter(names = {"-u", "--user"}, description = "username")
   private String username = null;
 
-  public static class PasswordConverter implements IStringConverter<String> {
-    public static final String STDIN = "stdin";
-
-    private enum KeyType {
-      PASS("pass:"), ENV("env:") {
-        @Override
-        String process(String value) {
-          return System.getenv(value);
-        }
-      },
-      FILE("file:") {
-        @SuppressFBWarnings(value = "PATH_TRAVERSAL_IN",
-            justification = "app is run in same security context as user providing the filename")
-        @Override
-        String process(String value) {
-          Scanner scanner = null;
-          try {
-            scanner = new Scanner(new File(value), UTF_8);
-            return scanner.nextLine();
-          } catch (IOException e) {
-            throw new ParameterException(e);
-          } finally {
-            if (scanner != null) {
-              scanner.close();
-            }
-          }
-        }
-      },
-      STDIN(PasswordConverter.STDIN) {
-        @Override
-        public boolean matches(String value) {
-          return prefix.equals(value);
-        }
-
-        @Override
-        public String convert(String value) {
-          // Will check for this later
-          return prefix;
-        }
-      };
-
-      String prefix;
-
-      private KeyType(String prefix) {
-        this.prefix = prefix;
-      }
-
-      public boolean matches(String value) {
-        return value.startsWith(prefix);
-      }
-
-      public String convert(String value) {
-        return process(value.substring(prefix.length()));
-      }
-
-      String process(String value) {
-        return value;
-      }
-    }
-
-    @Override
-    public String convert(String value) {
-      for (KeyType keyType : KeyType.values()) {
-        if (keyType.matches(value)) {
-          return keyType.convert(value);
-        }
-      }
-
-      return value;
-    }
-  }
-
   // Note: Don't use "password = true" because then it will prompt even if we have a token
   @Parameter(names = {"-p", "--password"},
       description = "password (can be specified as 'pass:<password>',"
 
 Review comment:
   I'm not sure why the original author choose not to describe these use-cases, so I left it as it was.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services