Hi Julio,

first of all, sorry in my previous e-mail to not use your correct name ;)

You get Insufficient credentials for all commands or only for bundle:* commands ? Could you check what you have in etc/*acl.cfg files ?

The same action works fine in Karaf standalone, right ?

Can you use the executeCommand() method provided by KarafTestSupport ?

For instance, in the Karaf itest, we do:

    @Test
    public void installUninstallCommand() throws Exception {
executeCommand("bundle:install mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-lang/2.4_6");

assertBundleInstalled("org.apache.servicemix.bundles.commons-lang");
executeCommand("bundle:uninstall org.apache.servicemix.bundles.commons-lang");

assertBundleNotInstalled("org.apache.servicemix.bundles.commons-lang");
    }

If you can't (or don't want to) use the KarafTestSupport, you have to use Subject.doAs() to execute the command session in "privileged" mode (something like:

            commandFuture = new FutureTask<String>(new Callable<String>() {
                @Override
                public String call() throws Exception {
                    Subject subject = new Subject();

subject.getPrincipals().addAll(Arrays.asList(principals));
return Subject.doAs(subject, new PrivilegedExceptionAction<String>() {
                        @Override
                        public String run() throws Exception {
                            return commandCallable.call();
                        }
                    });
                }
            });
)

Honestly, the easiest way is to directly use the executeCommand() provided by KarafTestSupport.

Regards
JB

On 05/28/2014 03:02 PM, Julio Carlos Barrera Juez wrote:
I'm using Karaf 3.0.1 and Pax Exam 3.5.0. I tried using these commands
in my test:

    bundle:install -s -f mvn:<gId>/<aId>/<v> (two times with different
    bundles)
    bundle:uninstall -f <bundleId>

I configured CommandSession without any option. I am still getting the
exception after calling the install command:

    bundle:install -s -f mvn:<gId>/<aId>/<v>
    java.lang.SecurityException: Insufficient credentials.
    ...

What is my mistake?

Thank you.

PD: I'm Julio, not Julian ;)


Julio C. Barrera Juez
Office phone: +34 93 357 99 27
Distributed Applications and Networks Area (DANA)
i2CAT Foundation, Barcelona
http://dana.i2cat.net <http://dana.i2cat.net/>


On 28 May 2014 14:01, Jean-Baptiste Onofré <[email protected]
<mailto:[email protected]>> wrote:

    Hi Julian,

    I guess that you use Karaf 3.0.0, right ?

    What's the command that you want to do (maybe bundle:* -f may help) ?

    You don't have to provide any use as it uses the default one
    (karaf), like when you run karaf bin bin/karaf.

    Regards
    JB


    On 05/28/2014 01:14 PM, Julio Carlos Barrera Juez wrote:

        Hello.

        I'm creating a Pax Exam test and I want to install a bundle in an
        specific moment of the test. I'm using a CommandSession to
        use bundle:install command. I get more or less all the stuff
        working,
        but I'm getting "java.lang.SecurityException: Insufficient
        credentials".

        My CommandSession is obtained locally (without getting
        explicitly the
        OSGi service with:

             final CommandSession commandSession =
             commandProcessor.__createSession(System.in, printStream,
        System.err);


        as I saw in many examples. What I need to do to inject
        credentials in
        this session. I've found many non-working solutions like:

             commandSession.put("__APPLICATION",
        System.getProperty("karaf.name <http://karaf.name>
             <http://karaf.name>", "root"));


             commandSession.put("USER", "karaf");

        Thank you!


        Julio C. Barrera Juez
        Office phone: +34 93 357 99 27 <tel:%2B34%2093%20357%2099%2027>
        Distributed Applications and Networks Area (DANA)
        i2CAT Foundation, Barcelona, Spain
        http://dana.i2cat.net <http://dana.i2cat.net/>


    --
    Jean-Baptiste Onofré
    [email protected] <mailto:[email protected]>
    http://blog.nanthrax.net
    Talend - http://www.talend.com



--
Jean-Baptiste Onofré
[email protected]
http://blog.nanthrax.net
Talend - http://www.talend.com

Reply via email to