0

I am writing a java program dor Oracle EBS that needs to switch user because of specific permissions defined on an user different than applmgr. The approach we're taking is to have a java class that will switch user on a separate session and then will list the file from a folder that the new user has access.

Any options available?

So far I could create two shell script files and then I run these shell scripts, one that will store environment variables and the other one will actually switch user and list the files.

Appreciate your help.

fdalsotto
  • 19
  • 2
  • 1
    Why not run your program as the appropriate user from the start? – Jeffrey Aug 23 '13 at 23:24
  • not sure if this will be possible. once a program is kicked off, it will have that user's permissions... – SnakeDoc Aug 23 '13 at 23:27
  • Your shell scripts will basically elevate your permissions, then kick off your program with those elevated permissions. So java still isn't the medium providing the su – SnakeDoc Aug 23 '13 at 23:29

3 Answers3

0

you could change the group permissions on the file. You could start a System.process( "su user && cat file" ); You could have the other user copy the file to you using a cronjob...

Dru
  • 1,398
  • 9
  • 6
0

You can try having Java launch a local command on the system then as part of that command launch another program (far from being very clean, but probably would work)

Check out this Class file for examples on launching local commands:

https://github.com/SnakeDoc/RPi_SerialGPS/blob/master/src/com/vanomaly/rpi/serial/gps/util/System.java

SnakeDoc
  • 13,611
  • 17
  • 65
  • 97
0

You should be able to use setuid - I expect there is a version available directly in Java, but otherwise, it shouldn't be that hard to make your own JNI code to do that.

However, it may be simpler to run a command that switches user (using su or sudo, for example) and then runs the required Java code.

Mats Petersson
  • 126,704
  • 14
  • 140
  • 227