Repository: tomee
Updated Branches:
  refs/heads/TOMEE-1887-cipher-command-hidden 2a7e0c4e9 -> 4aae16ccd


Remove execution block from the lookup block to not mix the exceptions


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/4aae16cc
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/4aae16cc
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/4aae16cc

Branch: refs/heads/TOMEE-1887-cipher-command-hidden
Commit: 4aae16ccd86f28e86675925a12c44a1e5df0730d
Parents: 2a7e0c4
Author: Jean-Louis Monteiro <jeano...@gmail.com>
Authored: Tue Jul 26 12:11:33 2016 +0200
Committer: Jean-Louis Monteiro <jeano...@gmail.com>
Committed: Tue Jul 26 12:11:33 2016 +0200

----------------------------------------------------------------------
 .../java/org/apache/openejb/cli/MainImpl.java   |  5 ++--
 .../java/org/apache/openejb/config/Cipher.java  | 31 +++++++++++---------
 2 files changed, 20 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/4aae16cc/container/openejb-core/src/main/java/org/apache/openejb/cli/MainImpl.java
----------------------------------------------------------------------
diff --git 
a/container/openejb-core/src/main/java/org/apache/openejb/cli/MainImpl.java 
b/container/openejb-core/src/main/java/org/apache/openejb/cli/MainImpl.java
index 5082309..66d11aa 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cli/MainImpl.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cli/MainImpl.java
@@ -69,8 +69,8 @@ public class MainImpl implements Main {
 
         // create the Options
         final Options options = new Options();
-        options.addOption(null, "version", false, "");
-        options.addOption("h", "help", false, "");
+        options.addOption(null, "version", false, "Display version");
+        options.addOption("h", "help", false, "Display help");
         options.addOption("e", "errors", false, "Produce execution error 
messages");
 
         CommandLine line = null;
@@ -241,6 +241,7 @@ public class MainImpl implements Main {
             final String footer = "\n" +
                 "Try 'openejb <command> --help' for help on a specific 
command.\n" +
                 "For example 'openejb deploy --help'.\n" +
+                "Important: to display exceptions while running commands, add 
-e option.\n" +
                 "\n" +
                 "Apache OpenEJB -- EJB Container System and Server.\n" +
                 "For additional information, see http://tomee.apache.org\n"; +

http://git-wip-us.apache.org/repos/asf/tomee/blob/4aae16cc/container/openejb-core/src/main/java/org/apache/openejb/config/Cipher.java
----------------------------------------------------------------------
diff --git 
a/container/openejb-core/src/main/java/org/apache/openejb/config/Cipher.java 
b/container/openejb-core/src/main/java/org/apache/openejb/config/Cipher.java
index 41d4d18..7996077 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/Cipher.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/Cipher.java
@@ -80,27 +80,29 @@ public class Cipher {
             return;
         }
 
+        final PasswordCipher cipher;
         try {
-            final PasswordCipher cipher = 
PasswordCipherFactory.getPasswordCipher(cipherName);
-
-            if (line.hasOption("decrypt")) {
-                final String pwdArg = (String) line.getArgList().get(0);
-                final char[] encryptdPassword = pwdArg.toCharArray();
-                System.out.println(cipher.decrypt(encryptdPassword));
-
-            } else { // if option neither encrypt/decrypt is specified, we 
assume
-                // it is encrypt.
-                final String plainPassword = (String) line.getArgList().get(0);
-                System.out.println(new String(cipher.encrypt(plainPassword)));
-            }
+            cipher = PasswordCipherFactory.getPasswordCipher(cipherName);
 
         } catch (final PasswordCipherException e) {
             System.out.println("Could not load password cipher implementation 
class. Check your classpath.");
-
             availableCiphers();
 
             throw new SystemExitException(-1);
         }
+
+        if (line.hasOption("decrypt")) {
+            final String pwdArg = (String) line.getArgList().get(0);
+            final char[] encryptdPassword = pwdArg.toCharArray();
+
+            System.out.println(cipher.decrypt(encryptdPassword));
+
+        } else { // if option neither encrypt/decrypt is specified, we assume
+            // it is encrypt.
+            final String plainPassword = (String) line.getArgList().get(0);
+
+            System.out.println(new String(cipher.encrypt(plainPassword)));
+        }
     }
 
     private static void availableCiphers() {
@@ -108,7 +110,8 @@ public class Cipher {
             final ResourceFinder finder = new ResourceFinder("META-INF/");
             final Map<String, Class<? extends PasswordCipher>> impls = 
finder.mapAllImplementations(PasswordCipher.class);
             System.out.println("Available ciphers are: " + Join.join(", ", 
impls.keySet()));
-        } catch (final Exception dontCare) {
+
+        } catch (final Exception ignore) {
             // no-op
         }
     }

Reply via email to