2

I'm going through the Java Tutorial Security trail but I'm stuck at the "See the Policy File Effects" lesson (See the Policy File Effects lesson link. I can make approach 1 work. This makes me think that I haven't typo'd my policy and signed jar file. Approach 2, editing the java.security file, isn't working.

I'm working on Windows 7 using Java 7 (installed at C:\Program Files\Java\jdk1.7.0_67). I do not have a .java.policy file (although I did try this).

Here's the exception

$ java -Djava.security.manager -cp sCount.jar Count C:/tstsecdata/data
Exception in thread "main" java.security.AccessControlException: access denied ("java.io.FilePermission" "C:\tstsecdata\data" "read")
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkRead(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at Count.main(Count.java:48)

What I've tried.

  1. I noticed that I had several JDKs installed. I uninstalled all and then re-installed jdk1.7.0_67.
  2. I noticed that 2 jre's are installed. One is Java\jdk1.7.0_61\jre. The other is Java\jre7. I found an explanation for this at Oracle JDK installs two JREs?. So I edited both java.security files and added the following line to each (after the policy.url.2 entry).

    policy.url.3=file:/c:/tstsec/exampleraypolicy

FWIW, here's the policy file:

/* AUTOMATICALLY GENERATED ON Tue Jun 02 09:39:05 EDT 2015*/
/* DO NOT EDIT */

keystore "file:/C:/tstsec/exampleraystore", "jks";

grant signedBy "susan" {
  permission java.io.FilePermission "C:\\tstsecdata\\*", "read";
};
  1. I tried making a copy of my edited java.security file and putting it in my /Users/ folder as ".java.policy".

My workstation is administered by the IT dept although I do have admin privileges. Is there some Windows 7 policy that is messing with me?

Community
  • 1
  • 1
dtwaratpdx
  • 21
  • 2

0 Answers0