Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File folder access through java with user name/password authentication

 
Ananth Chellathurai
Ranch Hand
Posts: 349
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

Here is my requirement, I have to search file folders with provided user credentials. I am deploying my application in a server, where I have a folder which has permissions for user1, and not for user2. By default File class uses java's permission for that folder to access it. How can I tie this up with authentication?

Thanks in advance.

Regards
Ananth Chellathurai
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How is the permissioning implemented on the folders for User1 and user2, is this on a *IX box?
 
Ananth Chellathurai
Ranch Hand
Posts: 349
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not clear on what an *IX box is?
Permission implemented on a file folder for local or domain users.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about that, *IX = UNIX or LINUX, are you running on windows?
 
Ananth Chellathurai
Ranch Hand
Posts: 349
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My requirement is for both linux and windows. And thats the reason for picking Java, platform independent. Its ok to have extra bit of code for various OS but need some clue on how to do it.


 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, next question is, what version of the JDK are you using? My understanding is that 1.6+ makes this alot easier.
 
Ananth Chellathurai
Ranch Hand
Posts: 349
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using java 1.6 update 10
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, OK this could be quite tough (I've never had to do this myself).

It looks like File supports:

boolean canExecute()
Tests whether the application can execute the file denoted by this abstract pathname.
boolean canRead()
Tests whether the application can read the file denoted by this abstract pathname.
boolean canWrite()
Tests whether the application can write the file denoted by this abstract pathname.

Problem is that by default your user will be the user running the java process.

Going _completely_ out on a limb here, could you perhaps spawn off a small java app that is run by the actual user you want to test the permissions against? Not sure if that would work.

Anyone else? This is out of my area of expertise!
 
Ananth Chellathurai
Ranch Hand
Posts: 349
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any API, that could help me do this. Any help? Is it not possible to do this at all.!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic