Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How do i create a java policy file that will allow · Reading the webpage http://

ID: 3621940 • Letter: H

Question

How do i create a java policy file that will allow

· Reading the webpage http://williams.comp.ncat.edu/comp620/index.htm but no other website

· Reading any file

· Writing a specific file (i.e. junk.txt)

· Writing a specific file only if the applet is signed by you

· Browsing the directories to select a file

Explanation / Answer

Dear... For creating a policy file we need to make use of the following Symbol in java: 1. file:${application} 2. file:${jars} 3. file:${ejbComponent} 4. file:${webComponent} 5. file:${connectorComponent Creating a New Policy File EX: syntex > policytool -file .policy keystore ".keystore"; grant signedBy "Junk" { permission java.io.FilePermission "${user.dir}/-", "read"; }; grant codeBase "http://someserver/myjar.jar" { permission java.util.PropertyPermission "file.encoding", "read"; } Code snippet of read and write of Privacy & Security // grant all classes loaded from h1.com ability to read empmyfile grant codeBase "http://h1.com/-" { permission java.io.FilePermission "c:\temp\myfile", "read"; }; // grant ability to create and write c: empmyfile // Note: if empmyfile does not exist, it could be created as a directory grant codeBase "http://h2.com/-" { permission java.io.FilePermission "c:\temp\myfile", "write"; }; // grant ability to list files in the user's home directory grant codeBase "http://h3.com/-" { permission java.io.FilePermission "${user.home}", "read"; }; // grant ability to read any file or directory under c: emp // Note: does not grant ability to read c: emp itself, i.e. no permission // to call File.list() on c: emp grant codeBase "http://h4.com/-" { permission java.io.FilePermission "c:\temp\-", "read"; }; // grant ability to delete any file or directory in c: empmydir // Note: does not grant ability to delete c: empmydir itself grant codeBase "http://h5.com/*" { permission java.io.FilePermission "c:\temp\mydir*", "delete"; }; // grant ability to execute (see Runtime.exec()) the file c:java.exe grant codeBase "http://h6.com/-" { permission java.io.FilePermission "c:\java.exe", "execute"; }; // grant ability to read and write any file in current directory // Note: this is equivalent to ${user.dir}/* grant codeBase "http://h7.com/-" { permission java.io.FilePermission "*", "read,write"; }; // grant ability to read any file under current directory // Note: this is equivalent to ${user.dir}/- grant codeBase "http://h8.com/-" { permission java.io.FilePermission "-", "read"; }; // grant ability to read any file grant codeBase "http://h9.com/-" { permission java.io.FilePermission "", "read"; };
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote