[ome-devel] change user id in the API

Matthias Dunda Matthias.Dunda at carus-it.com
Wed Mar 4 07:53:19 GMT 2009


Thanks Josh,

but I don't get it yet... :-(

I have

public class TestUserChange {
    public static void main(String[] args) throws Exception {
        omero.client client = new omero.client("localhost");
        ServiceFactoryPrx sf = client.createSession("root","ome");

        // this is the user to switch to
        Experimenter e = (Experimenter) sf.getQueryService().find(Experimenter.class.getName(), 100);

        Principal p = new Principal();

        ISessionPrx sessionPrx = sf.getSessionService();
        omero.model.Session session =
            sessionPrx.createSessionWithTimeout(p, 10000);

        omero.client sudo = new omero.client("localhost");
        sudo.joinSession(session.getUuid().getValue());


    }
}

from my understanding I need a new ServiceFactoryPrx from which I can get the appropriate updateService to create for example a new Project and all further substructures (you know what I mean) for a different user.

In the example above I want to login as root and then switch the user context to the Experimenter e which is loaded with user id 100.

In your example you wrote the comment for user name etc. after creation of the Pricipal p, but p does not provide meaningful methods to me...

I see Session has a setOwner method, but anyway, how do I get a new ServiceFactory then? :-Q

THanks again
Matthias



More information about the ome-devel mailing list