glassfish
  1. glassfish
  2. GLASSFISH-20818

Can't provide password for create-file-user

    Details

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

      Windows 7 x64 JDK7u25

      Description

      I tired to create a user in a file realm from my Java code (embedded glassfish v4).

      result = runner.
      run(command, "--authrealmname", realmName,
      "-groups", groups, "-passwordfile", userPasswordFilePath, user);

      I get the following exception running above command:

      SEVERE: PlainTextActionReporterFAILUREorg.jvnet.hk2.config.UnsatisfiedDependencyException: injection failed on com.sun.enterprise.security.cli.CreateFileUser.userpassword with class java.lang.StringDescription: create-file-user commandCannot find userpassword in create-file-user command model, file a bug
      Usage: create-file-user
      [--authrealmname ] [--target target]
      [--groups user_groups[:user_groups]*]
      [?|-help[=]] username

      --passwordfile option points to a file with AS_ADMIN_USERPASSWORD=password content.

      From asadmin create-file-user works fine for a glassfish instance

      I used maven to download source code and found that in CommandExecutorImpl.getParameters there is:

      if (globalOptions.size() > 0) {
      String pwfile = globalOptions.getOne(ProgramOptions.PASSWORDFILE);
      if (pwfile != null && pwfile.length() > 0) {
      Map passwords = CLIUtil.readPasswordFileOptions(pwfile, true);
      for (CommandModel.ParamModel opt : commandModel.getParameters()) {
      if (opt.getParam().password()) {
      String pwdname = opt.getName();
      String pwd = passwords.get(pwdname);//looks for userpassword, not for AS_ADMIN_USERPASSWORD
      if (pwd != null) {
      options.set(pwdname, pwd);
      }
      }
      }
      }
      }

      CLIUtil.readPasswordFileOptions(pwfile, true) method is called with withPrefix set to true

      for (Object key : prop.keySet()) {
      final String entry = (String)key;
      if (entry.startsWith(Environment.getPrefix())) {
      final String optionName = withPrefix ? entry :
      entry.substring(Environment.getPrefix().length()).toLowerCase(Locale.ENGLISH);//optionName is AS_ADMIN_USERPASSWORD, but should be userpassword
      final String optionValue = prop.getProperty(entry);
      passwordOptions.put(optionName, optionValue);
      }
      }

        Activity

        Hide
        pdudits added a comment -

        Proposed fix (using CLIUtil.readPasswordFileOptions(pwfile, false)) submitted to Payara. https://github.com/payara/Payara/pull/640

        Show
        pdudits added a comment - Proposed fix (using CLIUtil.readPasswordFileOptions(pwfile, false) ) submitted to Payara. https://github.com/payara/Payara/pull/640

          People

          • Assignee:
            martin.mares
            Reporter:
            mkwapisz
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: