users@glassfish.java.net

[gf-users] Re: org.glassfish.main.extras 4.1

From: Tomaz Majerhold <tomaz.majerhold_at_arnes.si>
Date: Wed, 04 Mar 2015 09:46:29 +0100

Dne 4.3.2015 ob 9:24 je Tomaz Majerhold zapisal(a):
> Dne 4.3.2015 ob 8:25 je Tomaz Majerhold zapisal(a):
>> I'm trying to port application from GF 3.1.2 to GF 4.1 but I have
>> problem with Junit tests because I can't use File realm for security.
>>
>> In my tests I use embedded GF 4.1 and with CommandRunner I'm adding
>> users to file realm, but having exception(not added) so my tests
>> fail, but this command is working in embedded GF 3.1.2.
>>
>> code:
>> -------
>> ... starting GF 4.1
>> ...
>> cmdResult = cmdRunner.run("set",
>> "server-config.security-service.activate-default-principal-to-role-mapping=true");
>> LOG.info(cmdResult.getOutput());
>> cmdResult = cmdRunner.run("create-file-user",
>> "--echo=true",
>> "--groups=service_admin:procurator:support",
>> "--authrealmname=file",
>> "--passwordfile=src/test/resources/META-INF/password.txt",
>> "test");
>> LOG.info("create-file-user:test = "+cmdResult.getOutput());
>> //add user support to file realm
>> cmdResult = cmdRunner.run("create-file-user",
>> "--echo=true",
>> "--groups=service_admin",
>> "--authrealmname=file",
>> "--passwordfile=src/test/resources/META-INF/password.txt",
>> "testSupport_at_test.si");
>> LOG.info("create-file-user:testSupport_at_test.si =
>> "+cmdResult.getOutput());
>> LOG.info("create-file-user:testSupport_at_test.si =
>> "+cmdResult.getFailureCause());
>> LOG.info("create-file-user:testSupport_at_test.si =
>> "+cmdResult.getExitStatus());
>>
>> LOG:
>> ------
>> 2462 [main] INFO si.arnes.predalnik.api.server.rest.test.BaseTest -
>> list-file-users1 = PlainTextActionReporterSUCCESSNo monitoring data
>> to report.
>> 2472 [main] INFO si.arnes.predalnik.api.server.rest.test.BaseTest -
>> create-file-user:test =
>> 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
>> 2482 [main] INFO si.arnes.predalnik.api.server.rest.test.BaseTest -
>> create-file-user:testSupport_at_test.si =
>> 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
>>
>> Any body know this issue?
>>
>> Regards, Tomaz
>
> Our mean in a team debug this issue and discover the problem in class
> CommandExecutorImpl(@author bhavanishankar_at_dev.java.net, @author
> sanjeeb.sahoo_at_sun.com) which implements
> org.glassfish.embeddable.CommandRunner
> which is part of package com.sun.enterprise.admin.cli.embeddable.
>
> The problem is in code on line 90
> ...
> Map<String, String> passwords =
> com.sun.enterprise.admin.cli.CLIUtil.readPasswordFileOptions(pwfile,
> true); // problem with true
>
> so if set on false
> Map<String, String> passwords =
> com.sun.enterprise.admin.cli.CLIUtil.readPasswordFileOptions(pwfile,
> false); // start working
>
> Anybody know for this?
>
> So what we do to avoid this problem:
> 1) We create snapshot for this class in our nexus
> 2) In maven dependency for test we add this before
> glassfish-embedded-all dependency so is loaded before glassfish and it
> start working adding users in file realm.
>
> It's hack, is anybody know how to avoid this hack and adding users to
> realms.
>
> Regards, Tomaz
Is anybody know what this actually mean in this function
readPasswordFileOptions(java.lang.String passwordFileName,boolean
withPrefix)

Regards, Tomaz