My app is completely written in java (we moved to java11 from java8) and was running fine under High Sierra:
new RandomAccessFile(file_on_network_volume, "rws")
gained access and execution continued.
Running under Catalina it fails with
java.io.FileNotFoundException: /Volumes/messages/xyz/FILE.xdt (Operation not permitted)
I understand that any application trying to access a network volume needs a special permission, I reviewed them in System Preferences and they can be removed with tccutil reset SystemPolicyNetworkVolumes [bundle_id]
for repeated testing.
How does the java code properly request the access right from the user so that the processing might continue?
What I did so far:
- changed the code to
AccessController.doPrivileged((PrivilegedExceptionAction<RandomAccessFile>) () -> new RandomAccessFile(file, "rws"));
That caused a JUnitTest run with IntelliJ to request the right by a dialogue
An application in IntelliJ IDEA requests access to files on a network volume
then the test succeeded to do the required operation on the network volume.
The effect is the permission indicated in system preferences as expected:
permission to access network volumes is present
- added in the Info.plist the entry
<key>NSNetworkVolumesUsageDescription</key> <string>@@bundle_name@@ benötigt Zugriff auf ein Netzwerkvolume.</string>
corresponding to the text in the dialog displayed to the user
But still something's missing. The app does not request the permission and consequently the operation fails. IntelliJ does something right that I didn't figure out so far.