Question: Your goal is to write, in any language, a program which implements the given security policy. The security policy will be based on our in-class


Your goal is to write, in any language, a program which implements the given security policy. The security policy will be based on our in-class discussion of the security policy for a house. The name of your house simulator will be called secure_house Policy Only users with an authorized key can enter the house. To enter the house, the user must first: 1. Insert their key in the lock 2. Turn the key in the lock 3. Enter the house Note that testing if a key is valid is done only when the key is turned. For turning the key and entering the house, it must be the same user that puts the key in the lock, turns the key, and enters the house A house can be rekeyed (this means that the old keys are no longer useable) with new keys only by the owner, and only if the owner is inside the house. Firefighters can enter with the secret key (literal string) FIREFIGHTER_SECRET_KEY There is only one lock and one door. The lock will always be accessed in the following way: 1. Insert key 2. turn the key 3. enter the house Other commands can be issued in between insert, turn, and enter. For example, the following situations will never happen: insert, enter insert, turn, insert turn, enter insert, turn, turn, enter . Interface You must implement the following command-line interface for your server: ./secure_house ... where is the name of the owner, and through are all authorized keys for the house. All inputs to the program (keys and names) will be [a-zA-Z0-9_1-] (alphanumeric, underscore, and dash). All matching is case- sensitive The input to your program (on standard input) will be a series of events separated by a newline. Your program must track these events and respond appropriately, while enforcing the security policy. Every input will end in a newline, and every response must end in a newline. Your program must continue to process input until there is no input left. How you do this will vary by programming language, try Googling for "End of file" (or EOF) and your programming language. You can simulate EOF on the command line by pressing CTRL-D (more info on this stackoverflow post). INSERT KEY inserts key key into the door. Response should be: KEY INSERTED BY TURN KEY turns the key in the door. Possible responses are: SUCCESS TURNS KEY or FAILURE UNABLE TO TURN KEY ENTER HOUSE enters the house Possible responses are: ACCESS DENIED or ACCESS ALLOWED WHO'S INSIDE? WHO'S INSIDE? Who is currently inside the house? Response must be a comma-separated list of user names, ordered by access time (earlier access first): , , ... or NOBODY HOME if there are no users in the house. CHANGE LOCKS ... wishes to rekey the house with new given keys , , ..., . Possible responses are: ACCESS DENIED or OK LEAVE HOUSE leaves the house. Possible responses are: OK or NOT HERE If any events are received that are not according to this specification, the response must be: ERROR Example Running the program as follows: ./secure_house selina foobar Given the input INSERT KEY adam key TURN KEY adam ENTER HOUSE adam INSERT KEY pat foobar TURN KEY pat ENTER HOUSE pat WHO'S INSIDE? 4 The program must produce the following output: KEY key INSERTED BY adam FAILURE adam UNABLE TO TURN KEY key ACCESS DENIED KEY foobar INSERTED BY pat SUCCESS pat TURNS KEY foobar ACCESS ALLOWED pat Implementation Your program must work on Ubuntu 18.04 64-bit with the default packages installed. In addition to the default packages the following packages for languages are also installed: C(gec ) C++ (g++) Kotlin 1.4.21 (Custom install) PHP 7.2 ( php-cli) Python 2 (python ) Python 3 (python3 ) Java ( default-jre and default-jdk) Rust ( rustc ) Ruby (ruby-full) Node.js ( nodejs and npm) Mono (Custom install) . Go (1.15.6, custom install) If there's a package that you need, please ask on the course piazza and I'll have it installed for everyone. Java is already installed. If you need to set up a virtual machine for your development: VirtualBox is a free and open-source VM system. We've created a test script called test.sh to help you test your program before submitting. 1. Download test.sh to the directory where your code lives (including README and Makefile). 2. Ensure that test.sh is executable chmod +x test.sh 3. Run: ./test.sh There is also a test_debug sh that gives you the output of your program. This can help you with debugging when the program appears to work from the command line, but not in the test.sh script (it's happened before). Your program must be able to accept arbitrarily large inout (and this will be tested by the autograder). Your goal is to write, in any language, a program which implements the given security policy. The security policy will be based on our in-class discussion of the security policy for a house. The name of your house simulator will be called secure_house Policy Only users with an authorized key can enter the house. To enter the house, the user must first: 1. Insert their key in the lock 2. Turn the key in the lock 3. Enter the house Note that testing if a key is valid is done only when the key is turned. For turning the key and entering the house, it must be the same user that puts the key in the lock, turns the key, and enters the house A house can be rekeyed (this means that the old keys are no longer useable) with new keys only by the owner, and only if the owner is inside the house. Firefighters can enter with the secret key (literal string) FIREFIGHTER_SECRET_KEY There is only one lock and one door. The lock will always be accessed in the following way: 1. Insert key 2. turn the key 3. enter the house Other commands can be issued in between insert, turn, and enter. For example, the following situations will never happen: insert, enter insert, turn, insert turn, enter insert, turn, turn, enter . Interface You must implement the following command-line interface for your server: ./secure_house ... where is the name of the owner, and through are all authorized keys for the house. All inputs to the program (keys and names) will be [a-zA-Z0-9_1-] (alphanumeric, underscore, and dash). All matching is case- sensitive The input to your program (on standard input) will be a series of events separated by a newline. Your program must track these events and respond appropriately, while enforcing the security policy. Every input will end in a newline, and every response must end in a newline. Your program must continue to process input until there is no input left. How you do this will vary by programming language, try Googling for "End of file" (or EOF) and your programming language. You can simulate EOF on the command line by pressing CTRL-D (more info on this stackoverflow post). INSERT KEY inserts key key into the door. Response should be: KEY INSERTED BY TURN KEY turns the key in the door. Possible responses are: SUCCESS TURNS KEY or FAILURE UNABLE TO TURN KEY ENTER HOUSE enters the house Possible responses are: ACCESS DENIED or ACCESS ALLOWED WHO'S INSIDE? WHO'S INSIDE? Who is currently inside the house? Response must be a comma-separated list of user names, ordered by access time (earlier access first): , , ... or NOBODY HOME if there are no users in the house. CHANGE LOCKS ... wishes to rekey the house with new given keys , , ..., . Possible responses are: ACCESS DENIED or OK LEAVE HOUSE leaves the house. Possible responses are: OK or NOT HERE If any events are received that are not according to this specification, the response must be: ERROR Example Running the program as follows: ./secure_house selina foobar Given the input INSERT KEY adam key TURN KEY adam ENTER HOUSE adam INSERT KEY pat foobar TURN KEY pat ENTER HOUSE pat WHO'S INSIDE? 4 The program must produce the following output: KEY key INSERTED BY adam FAILURE adam UNABLE TO TURN KEY key ACCESS DENIED KEY foobar INSERTED BY pat SUCCESS pat TURNS KEY foobar ACCESS ALLOWED pat Implementation Your program must work on Ubuntu 18.04 64-bit with the default packages installed. In addition to the default packages the following packages for languages are also installed: C(gec ) C++ (g++) Kotlin 1.4.21 (Custom install) PHP 7.2 ( php-cli) Python 2 (python ) Python 3 (python3 ) Java ( default-jre and default-jdk) Rust ( rustc ) Ruby (ruby-full) Node.js ( nodejs and npm) Mono (Custom install) . Go (1.15.6, custom install) If there's a package that you need, please ask on the course piazza and I'll have it installed for everyone. Java is already installed. If you need to set up a virtual machine for your development: VirtualBox is a free and open-source VM system. We've created a test script called test.sh to help you test your program before submitting. 1. Download test.sh to the directory where your code lives (including README and Makefile). 2. Ensure that test.sh is executable chmod +x test.sh 3. Run: ./test.sh There is also a test_debug sh that gives you the output of your program. This can help you with debugging when the program appears to work from the command line, but not in the test.sh script (it's happened before). Your program must be able to accept arbitrarily large inout (and this will be tested by the autograder)