Question: DO NOT COPY PASTE ANSWERS FROM OTHER PEOPLE'S QUESTIONS Implement this in C or C++ The name of your house simulator will be called secure_house.
DO NOT COPY PASTE ANSWERS FROM OTHER PEOPLE'S QUESTIONS
Implement this in C or C++
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 put their key in the lock, then turn the lock, then enter the house, only if the key is valid. A house can be rekeyed 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.
Police can enter as long as their user_name starts with officer_with_warrant and their key is POLICE_SECRET_KEY.
Interface
You must implement the following command-line interface for your server:
./secure_house...
where
All inputs to the program (keys and names) will be [a-zA-Z0-9_\-] (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.
INSERT KEY
TURN KEY
ENTER HOUSE
WHO'S INSIDE?
Who is currently inside the house? Response should be a comma-separated list of user names, ordered by access time (earlier access first):
CHANGE LOCKS...
LEAVE HOUSE
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?
The program will 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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
