Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 3 - Security permission Develop a program that lists the files and subdirectories in a directory, using a security manager and an associated security
Question 3 - Security permission Develop a program that lists the files and subdirectories in a directory, using a security manager and an associated security policy file. The program, called ListFiles, programmatically sets the policy file (which is in the working directory), installs a security manager, obtains and displays the files and subdirectories in a directory. The directory is specified as a command-line argument to the program. If there is any exception, the program should display the exception message and end its execution. (Hint: To obtain the files and subdirectories in a directory, you may use the list method of the File class.) The security policy file, called ListFiles.policy, grants read access to the directory C:\Program Files\Java and all its subdirectories (recursively). Submit both the program and the policy file. These are sample outputs of running the program > java ListFiles C:\Program Files\Java jdk-14.0.1 jdk1.8.0_77 jre1.8.0_77 jre7 > java ListFiles C:\Program Files\Java\jdk-14.0.1 bin conf COPYRIGHT include jmods legal lib release > java ListFiles C:\ Exception: access denied ("java.io.FilePermission" "C:\" "read") > java ListFiles C:\Windows Exception: denied ("java.io.FilePermission" "C:\Windows" "read") access
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started