• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to enforce user management with file reading in java?

 
Ranch Hand
Posts: 55
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I need to enforce user management with respect to the file reading in java applicaiton.

If the applicaiton is running under the other usernames it should not be allowed to read the file.

Kindly advise how to achieve this..
 
ilias basha
Ranch Hand
Posts: 55
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can we enforce user based read privileges in java?? or is it the responsibility of the OS-file system??
 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is handled purely through the OS. You should be able to tell the OS the file is only readable for a specific user though. The problem is that this is mostly platform dependent. For example, in Unix you should be able to handle these permissions by making Runtime.exec() execute chmod.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could get the current user name with:

and not give unauthorised users access. Of course, this only prevents access through your application. The file would still be accessible through other means.
 
ilias basha
Ranch Hand
Posts: 55
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Stephan, Thanks for the suggestion But my application runs on the windows environment, and using i am able to hide and make read only file in windows but was not sure of the windows32 api instructions to make changes in privileges of the file for restricting access though.

Joe, Thanks for the property to get the user name of the OS, but my requirement is beyond application, infact it should enforce restriction in OS level
reply
    Bookmark Topic Watch Topic
  • New Topic