test_class.file: agent/jvm/src/test/java/org/jolokia/jvmagent/client/command/EncryptCommandTest.java
test_class.identifier: EncryptCommandTest
test_case.body: @Test
      public void testEncryptDecrypt() throws Exception {
          String passwd = "test 123";
  
          JCPPTest keyHolder = new JCPPTest();
  
          EncryptCommand ec = new EncryptCommand(keyHolder);
          OptionsAndArgs oaa = new OptionsAndArgs(CommandDispatcher.getAvailableCommands(),"encrypt", passwd);
          PrintStream original = System.out;
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          System.setOut(new PrintStream(baos));
          ec.execute(oaa, null, null);
          System.setOut(original);
  
          Matcher matcher = Pattern.compile("^\\[\\[(.*)]]").matcher(baos.toString());
          matcher.find();
          String encrypted = matcher.group(1);
  
          JolokiaCipher jolokiaCipher = new JolokiaCipher(keyHolder);
          String decrypted = jolokiaCipher.decrypt(encrypted);
          assertEquals(decrypted,passwd);
      }
test_case.class_method_signature: EncryptCommandTest.testEncryptDecrypt()
test_case.full_signature: @Test public void testEncryptDecrypt()
test_case.identifier: testEncryptDecrypt
test_case.invocations: getAvailableCommands setOut execute setOut matcher compile toString find group decrypt assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testEncryptDecrypt()
focal_class.declarator: keyHolder
focal_class.modifier: private final
focal_class.original_string: private final JolokiaCipher.KeyHolder keyHolder;
focal_class.type: JolokiaCipher.KeyHolder
focal_class.var_name: keyHolder
focal_class.file: agent/jvm/src/main/java/org/jolokia/jvmagent/client/command/EncryptCommand.java
focal_class.identifier: EncryptCommand
focal_class.class_method_signature: EncryptCommand.EncryptCommand()
focal_class.full_signature: public  EncryptCommand()
focal_class.identifier: EncryptCommand
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  EncryptCommand()
focal_class.class_method_signature: EncryptCommand.EncryptCommand(JolokiaCipher.KeyHolder pKeyHolder)
focal_class.full_signature: public  EncryptCommand(JolokiaCipher.KeyHolder pKeyHolder)
focal_class.identifier: EncryptCommand
focal_class.modifiers: public
focal_class.parameters: (JolokiaCipher.KeyHolder pKeyHolder)
focal_class.signature:  EncryptCommand(JolokiaCipher.KeyHolder pKeyHolder)
focal_class.class_method_signature: EncryptCommand.getName()
focal_class.full_signature: @Override String getName()
focal_class.identifier: getName
focal_class.modifiers: @Override
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getName()
focal_class.class_method_signature: EncryptCommand.execute(OptionsAndArgs pOpts, Object pVm, VirtualMachineHandler pHandler)
focal_class.full_signature: @Override int execute(OptionsAndArgs pOpts, Object pVm, VirtualMachineHandler pHandler)
focal_class.identifier: execute
focal_class.modifiers: @Override
focal_class.parameters: (OptionsAndArgs pOpts, Object pVm, VirtualMachineHandler pHandler)
focal_class.return: int
focal_class.signature: int execute(OptionsAndArgs pOpts, Object pVm, VirtualMachineHandler pHandler)
focal_class.class_method_signature: EncryptCommand.getPasswordFromConsoleOrStdin(OptionsAndArgs pOpts)
focal_class.full_signature: private String getPasswordFromConsoleOrStdin(OptionsAndArgs pOpts)
focal_class.identifier: getPasswordFromConsoleOrStdin
focal_class.modifiers: private
focal_class.parameters: (OptionsAndArgs pOpts)
focal_class.return: String
focal_class.signature: String getPasswordFromConsoleOrStdin(OptionsAndArgs pOpts)
focal_class.superclass: extends AbstractBaseCommand
focal_method.body: @Override
      int execute(OptionsAndArgs pOpts, Object pVm, VirtualMachineHandler pHandler)
              throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
          try {
              List<String> args = pOpts.getExtraArgs();
              String password = args.size() == 0 ?
                      getPasswordFromConsoleOrStdin(pOpts) :
                      args.get(0);
              JolokiaCipher jolokiaCipher = keyHolder != null ?
                      new JolokiaCipher(keyHolder) :
                      new JolokiaCipher();
              String encrypted = jolokiaCipher.encrypt(password);
              System.out.printf("[[%s]]%n", encrypted);
              return 0;
          } catch (GeneralSecurityException exp) {
              throw new InvocationTargetException(exp,"Can not encrypt password");
          }
      }
focal_method.class_method_signature: EncryptCommand.execute(OptionsAndArgs pOpts, Object pVm, VirtualMachineHandler pHandler)
focal_method.full_signature: @Override int execute(OptionsAndArgs pOpts, Object pVm, VirtualMachineHandler pHandler)
focal_method.identifier: execute
focal_method.invocations: getExtraArgs size getPasswordFromConsoleOrStdin get encrypt printf
focal_method.modifiers: @Override
focal_method.parameters: (OptionsAndArgs pOpts, Object pVm, VirtualMachineHandler pHandler)
focal_method.return: int
focal_method.signature: int execute(OptionsAndArgs pOpts, Object pVm, VirtualMachineHandler pHandler)