John said:
Is there a way in java of getting the access control lists of file in
windows/linux, i.e. does user x have access to file y.
I consider it bad practice to try to duplicate the OS's algorithm for
deciding access, since this is an area subject to OS/FS enhancements,
and the access information itself may be hidden from non-root access.
For example, suppose you hard-coded the original Unix check
(owner/group/other) and then ran into the ACL extensions.
In general, the only robust way to determine A can perform system
call B is for A to go ahead and do it. I hate the style of making
snooping calls to predict whether the payload call will work, as the
payload call might still fail (for example, because of an external
change happening in the timing window) but that failure is hard to
test and the coder not likely to have coded for it properly.
In your example, make a process that runs as user x and accesses
file y (without damaging it) then reports its success ot failure.