Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

DO NOT COPY PASTE ANSWERS FROM OTHER PEOPLE'S QUESTIONS THIS ONE IS DIFFERENT! Write a C or C++ program that implements a home security policy.

DO NOT COPY PASTE ANSWERS FROM OTHER PEOPLE'S QUESTIONS THIS ONE IS DIFFERENT!

Write a C or C++ program that implements a home security policy.

The name of the simulator should be secure_home

The policy states that only users with an authorized key can enter the home. To enter the home, the user must first put their key in the lock, then turn the lock, then enter the home, only if the key is valid. A home can be rekeyed with new keys only by the owner, and only if the owner is inside the home.

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.

You must implement the following command-line interface for your server:

./secure_home ...

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_\-] (alphanumeric, underscore, and dash). All matching is case-sensitive.

The input to the program (on standard input)) will be a series of events separated by a newline. The 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

User_name 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 is currently inside the home? Response should 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 home.

CHANGE LOCKS ...

wishes to rekey the home 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_home that lady

Given the input:

INSERT KEY sadaf key

TURN KEY sadaf

ENTER HOUSE sadaf

INSERT KEY that lady

TURN KEY that

ENTER HOUSE that

WHO'S INSIDE?

The program will produce the following output:

KEY key INSERTED BY sadaf

FAILURE sadaf UNABLE TO TURN KEY key

ACCESS DENIED

KEY lady INSERTED BY that

SUCCESS that TURNS KEY lady

ACCESS ALLOWED

Pat

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design

Authors: Marion Donnie Dutton Don F. Seaman

14th Edition Globel Edition

1292107634, 978-1292107639

More Books

Students also viewed these Databases questions

Question

differentiate the function ( x + 1 ) / ( x ^ 3 + x - 6 )

Answered: 1 week ago