permissions
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Crazy_Gal
Posted On:   Thursday, April 17, 2003 10:10 PM

I have written the following code: //this is saved in /home/myname/main/second/ package second; public class secThread extends Thread{ public void run(){ FileWriter fw = new FileWriter("file.txt"); fw.close; } } ------------------------------- //this is saved in /home/myname/main/ import second.secThread; public class mainProg{ public static void main(String args[]) { secThread st = new secThread(); st.start(); } } ----------------------------------    More>>

I have written the following code:

			


//this is saved in /home/myname/main/second/


package second;

public class secThread extends Thread{

public void run(){

FileWriter fw = new FileWriter("file.txt");

fw.close;

}

}




-------------------------------

			

//this is saved in /home/myname/main/

import second.secThread;

public class mainProg{

public static void main(String args[]) {

secThread st = new secThread();

st.start();

}

}



----------------------------------


my policyfile has the following entry"

			

grant codeBase "file:/home/myname/main/*"

permission java.io.FilePermission " < >";

};





notice, secThread does not have permission to write to anyfile

---------------------------------


when i run mainProg, using the default security manager and the policyfile above, i do not get an exception. However, I think I should because secThread is writing to a file, but it does not have java.io.FilePermission, "write" to write to any file!



Can someone please help me out here?

I am using JDK1.3



Thanks

SG
   <<Less

Re: permissions

Posted By:   Stuart_Thiel  
Posted On:   Tuesday, June 3, 2003 12:44 PM

I don't know if this helps, but I was running from the command line and getting pretty peeved that my security wasn't implemented. I was doing something like:



java -Djava.security.policy=all.security repop



and it ignored the policy in all.security (a file).



I then looked around and slapped my forehead when I saw that there was no security manager running, and all I needed to do was pass another parameter:



-Djava.security.manager



This tells java to run with the default security manager (defined in the java.security file in the SDK lib somewhere ... a find will dig it up). The final commandline command was:



java -Djava.security.policy=all.security

&nbps;&nbps;&nbps;-Djava.security.manager repop



(Please note that repop is the incredibly descriptive name of my class file).



I hope this helps, or at least clears things up for other people who were in my position.

Re: permissions

Posted By:   Christopher_Koenigsberg  
Posted On:   Friday, April 18, 2003 07:07 AM

Since you are running an application, not an applet, I think (?) the security permissions do not apply.

About | Sitemap | Contact