[ome-devel] Using omero.gateway.Gateway for sudo-connections

Christian Carsten Sachs c.sachs at fz-juelich.de
Fri Apr 15 11:47:11 BST 2016


Hello,

I'd like to connect to OMERO via Java using a sudo connection, i.e.
login as an admin user, and then perform actions as another user.

While there is example code at
https://github.com/openmicroscopy/openmicroscopy/blob/master/examples/OmeroClients/sudo.java
the code 'manually' establishes a connection, while the current
developer documentation urges to use the omero.gateway.Gateway class to
manage the connection (as far as I read, this is the modern and
recommended way).

Is there any way to use omero.gateway.Gateway for a sudo connection?

I played around with something like this,

adminUser = gateway.connect(ADMIN_CREDENTIALS);

adminCtx = new SecurityContext(adminUser.getGroupId());

user =
gateway.getFacility(AdminFacility.class).lookupExperimenter(adminCtx,
"normalUserName");

ctx = new SecurityContext(user.getGroupId());

but using ctx lateron fails; I assume the necessary services are not
properly started/connected, what gateway would normally do upon login;
unfortunately I don't seem to find a way to force the gateway object to
do this lateron for another user ...

I looked around a bit and have some ideas how it might be done manually
... within omero.gateway.Gateway, but unfortunately as the necessary
variables appear private I can't really access that from outside code.

Best regards,
Christian Sachs


------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzender des Aufsichtsrats: MinDir Dr. Karl Eugen Huthmacher
Geschaeftsfuehrung: Prof. Dr.-Ing. Wolfgang Marquardt (Vorsitzender),
Karsten Beneke (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
Prof. Dr. Sebastian M. Schmidt
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------



More information about the ome-devel mailing list