Skip to main content

Problem with create-file-user

2 replies [Last post]
mkwapisz
Offline
Joined: 2007-01-31
Points: 0

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

I get the following exception:

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

I use --passwordfile option to point to file with AS_ADMIN_USERPASSWORD property.

From asadmin everything works fine, but not from my Java code. With glassfish 3.1.2 embedded libraries it work fine also. Can you help me. What I do wrong.

I looked into the code and found in CommandExecutorImpl.getParameters :

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);
if (pwd != null) {
options.set(pwdname, pwd);
}
}
}
}
}

CLIUtil.readPasswordFileOptions(pwfile, true); is called with withPrefix set to true and in this method (in my opinion withPrefix should be set to false)

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);
final String optionValue = prop.getProperty(entry);
passwordOptions.put(optionName, optionValue);
}
}

passwordOptions has one entry AS_ADMIN_USERPASSWORD -> password, but getParemetres method looks for "userpassword" entry.

I am curious how it works from asadmin tool. Are GF libraries different from embedded GF?

Regards
Marcin

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
atrajano
Offline
Joined: 2004-04-08
Points: 0

Have you found a work around? I am encountering hte same problem with maven-embedded-glassfish-plugin

mkwapisz
Offline
Joined: 2007-01-31
Points: 0

Hi,
I filed an issue, but there is no solution and I do not know about any reasonable workaround, sorry.

Regards
Marcin