0

I have this file:

➜ ✗ ll ltr /Users/eladb/WorkspaceQa/sdk-service/src/main/resources/convert_conditions.sh

-rwxrwxrwx  1 eladb  eng   882B Jun 11 16:38 /Users/eladb/WorkspaceQa/sdk-service/src/main/resources/convert_conditions.sh

I try to read it from java:

        new FileInputStream(new File("/Users/eladb/WorkspaceQa/sdk-service/src/main/resources/convert_conditions.sh"));

but i get an error:

java.security.AccessControlException: access denied ("java.io.FilePermission" "/Users/eladb/WorkspaceQa/sdk-service/src/main/resources/convert_conditions.sh" "read")
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472) ~[?:1.8.0_91]
    at java.security.AccessController.checkPermission(AccessController.java:884) ~[?:1.8.0_91]
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) ~[?:1.8.0_91]
    at java.lang.SecurityManager.checkRead(SecurityManager.java:888) ~[?:1.8.0_91]
    at java.io.FileInputStream.<init>(FileInputStream.java:127) ~[?:1.8.0_91]

how come, as everyone has a read permission to that file?

Elad Benda
  • 35,076
  • 87
  • 265
  • 471
  • You are not running this java line from a simple java program on the command line, are you? It seems you have enabled the `SecurityManager`, so the root issue could be anywhere in the configuration. What is the context exactly? – Hugues M. Jun 13 '17 at 21:38

1 Answers1

0

The operating system's file permissions have nothing to do with it. See the stack trace, or indeed the Javadoc of the exception. This exception comes from the Java security manager, not the operating system. You are running under a security manager (why?) and you haven't granted yourself permission to access that file in your .policy file.

user207421
  • 305,947
  • 44
  • 307
  • 483