glassfish
  1. glassfish
  2. GLASSFISH-20921

Password from passwords file provided for create-password-alias command with --passwordfile option aren't set properly

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 4.0
    • Fix Version/s: None
    • Component/s: admin, embedded
    • Labels:
      None
    • Environment:

      maven-embedded-glassfish-plugin
      executing embedded-glassfish:admin

      Description

      I have following configuration for maven-embedded-glassfish-plugin:

      <groupId>org.glassfish.embedded</groupId>
      <artifactId>maven-embedded-glassfish-plugin</artifactId>
      <!--<version>3.1.2.2</version>-->
      <version>4.0</version>
      ...
      <executions>
        <execution>
           <id>deploy-binarystorage</id>
           <phase>none</phase>
           <goals>
             <goal>admin</goal>
           </goals>
           <configuration>
             <commands>
               <command>create-password-alias --passwordfile src/test/resources/passwords.file my-alias</command>
             </commands>
           </configuration>
         </execution>
      <executions>
      

      content of the passwords.file is following:

      AS_ADMIN_ALIASPASSWORD=tests
      

      When I run my maven build I got following message:

      INFO: Ran command [create-password-alias --passwordfile src/test/resources/passwords.file my-alias]. Exit Code [FAILURE], Output = 
      [PlainTextActionReporterFAILUREorg.jvnet.hk2.config.UnsatisfiedDependencyException: 
      injection failed on com.sun.enterprise.security.cli.CreatePasswordAlias.aliasPassword with class java.lang.StringDescription: 
      create-password-alias 
      commandCannot find aliasPassword in create-password-alias command model, file a bug
          Usage: create-password-alias aliasname 
      ]
      

      Investigation lead me to the following peace of code in the com.sun.enterprise.admin.cli.embeddable.CommandExecutorImpl:
      (comments are mine)

      if (pwfile != null && pwfile.length() > 0) {
        // following line will read passwords from file and create a Map instance where 
        // key is "AS_ADMIN_ALIASPASSWORD" and value is "tests"
        Map<String, String> passwords = CLIUtil.readPasswordFileOptions(pwfile, true);
        for (CommandModel.ParamModel opt : commandModel.getParameters()) {
          if (opt.getParam().password()) {
            String pwdname = opt.getName();
            // following line will try to get password value from map using parameter name "aliaspassword"
            // and obviously will fail because map contain only key "AS_ADMIN_ALIASPASSWORD"
            // preventing command from execution 
            String pwd = passwords.get(pwdname);
            if (pwd != null) {
              options.set(pwdname, pwd);
            }
          }
        }
      }
      

      Looking into CLIUtil.readPasswordFileOptions method it became obvious that if called using "false" as second parameter we get proper map instance with "aliaspasseord" as key and "tests" as value and command will not fail. I assume that this is a bug and fix must be like:

      - Map<String, String> passwords = CLIUtil.readPasswordFileOptions(pwfile, true);
      + Map<String, String> passwords = CLIUtil.readPasswordFileOptions(pwfile, false);
      

        Activity

        Hide
        gray added a comment -

        As always... no reaction

        Show
        gray added a comment - As always... no reaction

          People

          • Assignee:
            Chris Kasso
            Reporter:
            gray
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: