Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The create-file-user subcommand with passwordfile option isn't usable in embedded glassfish. #23772

Closed
kosakak opened this issue Jan 31, 2022 · 0 comments · Fixed by #23773
Closed

Comments

@kosakak
Copy link
Contributor

kosakak commented Jan 31, 2022

Environment Details

  • GlassFish Version (and build number): glassfish-embedded-all (built from the commit d990905 as of Jan. 10, 2022)
  • JDK version: 11.0.13+8
  • OS: CentOS 7.7

Problem Description

In Embedded GlassFish, when running the create-file-user subcommand with the --passwordfile option, the following error occurs and fails to execute the command.

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 <authrealm_name>] [--target target] 
	    [--groups user_groups[:user_groups]*] 
	    [-?|--help[=<help(default:false)>]] username

Steps to reproduce

  1. Create a password file as password.txt.

    AS_ADMIN_USERPASSWORD=mypassword
    

    References:

    • create-file-user - Eclipse GlassFish Server Reference Manual
      https://glassfish.org/docs/latest/reference-manual/create-file-user.html

      You can use the --passwordfile option of the asadmin(1M) command to specify the password for the user. The password file entry must be of the form AS_ADMIN_USERPASSWORD=user-password.

    • To Set a Password From a File - Eclipse GlassFish Server Security Guide
      https://glassfish.org/docs/latest/security-guide/system-security.html#GSSCG00096

      Instead of typing the password at the command line, you can access the password for a command from a file such as passwords.txt. The --passwordfile option of the asadmin utility takes the name of the file that contains the passwords. The entry for a password in the file must have the AS_ADMIN_ prefix followed by the password name in uppercase letters.

  2. Save the following program as Program.java.

    import org.glassfish.embeddable.CommandResult;
    import org.glassfish.embeddable.CommandRunner;
    import org.glassfish.embeddable.GlassFish;
    import org.glassfish.embeddable.GlassFishProperties;
    import org.glassfish.embeddable.GlassFishRuntime;
    
    public class Program {
        public static void main(String[] args) throws Exception {
            GlassFishRuntime runtime = GlassFishRuntime.bootstrap();
            GlassFishProperties glassfishProperties = new GlassFishProperties();
            glassfishProperties.setPort("http-listener", 8080);
            glassfishProperties.setPort("https-listener", 8181);
            GlassFish glassfish = runtime.newGlassFish(glassfishProperties);
            glassfish.start();
                CommandRunner commandRunner = glassfish.getCommandRunner();        
                CommandResult commandResult = commandRunner.run(
                         "create-file-user", "--passwordfile=password.txt", "user1"); // Specify the text file of step1
                System.out.println("status: " + commandResult.getExitStatus());
                System.out.println("output: " + commandResult.getOutput());
                System.out.println("cause: " + commandResult.getFailureCause());
        }
    }
  3. Compile and run it with glassfish-embedded-all.jar(*).

    $ javac -cp glassfish-embedded-all.jar Program.java
    $ java -cp .:glassfish-embedded-all.jar Program

    (*) appserver/extras/embedded/all/target/glassfish-embedded-all.jar

Then UnsatisfiedDependencyException occurs and the create-file-user subcommand fails.

    status: FAILURE
    output: 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 <authrealm_name>] [--target target] 
	    [--groups user_groups[:user_groups]*] 
	    [-?|--help[=<help(default:false)>]] username

    cause: org.jvnet.hk2.config.UnsatisfiedDependencyException: injection failed on com.sun.enterprise.security.cli.CreateFileUser.userpassword with class java.lang.String

Impact of Issue

Unable to use create-file-user subcommand with passwordfile option in embedded glassfish.

kosakak added a commit to kosakak/glassfish that referenced this issue Jan 31, 2022
…ile option isn't usable in embedded glassfish.

Signed-off-by: kosakak <kosaka.koki@fujitsu.com>
arjantijms added a commit that referenced this issue Feb 2, 2022
Fix #23772 The create-file-user subcommand with passwordfile option isn't usable in embedded glassfish.
arjantijms pushed a commit to arjantijms/glassfish that referenced this issue Feb 6, 2022
…ile option isn't usable in embedded glassfish.

Signed-off-by: kosakak <kosaka.koki@fujitsu.com>
arjantijms added a commit that referenced this issue Feb 6, 2022
Fix #23772 The create-file-user subcommand with passwordfile option i…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant