Security Managers and Permissions
Contents Problem Description Solution
I. Problem Description Develop a program that allows the user to check whether the text input contains bad words or not. A sentence is considered to have bad words if it contains either “sex” or “drug”. However, the sentence is not bad if it contains either “drugget”, “druggist”, or “drugstore”. A sample GUI is shown in the next slide.
II. Solution Developing the Model Developing the View Adding a Listener to Insert Button
1. Developing the Model 1.1 Creating a .policy File in the Project's Root Folder 1.2 Developing the Test Class 1.3 Developing the WordCheck Class 1.4 Developing the WordPermission Class 1.5 Running the Test Class
1.1 Creating a .policy File in the Project's Root Folder This policy is for two actions: avoid and insert
1.2 Developing the Test Class java -Djava.security.manager -Djava.security.policy=WordPermission.policy permission.model.WordCheckTest
1.3 Developing the WordCheck Class
1.4 Developing the WordPermission Class
1.5 Running the Test Class MUST run using the command line!
2. Developing the View
3. Adding a Listener to Insert Button 3.1 Setting the Policy 3.2 Developing the Listener
3.1 Setting the Policy
3.2 Developing the Listener