Write a java program that implements a home security policy.
The name of the simulator s...
Engineering, 14.02.2020 18:29 rkingmitch8074
Write a java 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
that
Answers: 2
Engineering, 04.07.2019 16:10
The force on a cutting tool are 2600n vertically downward and 2100 horizontal. determine the resultant force acting on the tool and the angle at which it acts.
Answers: 1
Engineering, 04.07.2019 18:10
Consider a large isothermal enclosure that is maintained at a uniform temperature of 2000 k. calculate the emissive power of the radiation that emerges from a small aperture on the enclosure surface. what is the wavelength ? , below which 10% of the emission is concentrated? what is the wavelength ? 2 above which 10% of the emission is concentrated? determine the wavelength at which maximum spectral emissive power occurs. what is the irradiation incident on a small object placed inside the enclosure?
Answers: 2
Engineering, 04.07.2019 18:10
Which of the following components of a pid controlled accumulates the error over time and responds to system error after the error has been accumulated? a)- proportional b)- derivative c)- integral d)- on/off.
Answers: 2
Engineering, 04.07.2019 18:10
Calculate the bore of a cylinder that has a stroke of 18 inches and an extension time of 6 seconds at a flow rate of 4 gal/min.
Answers: 3
Biology, 06.07.2019 01:30
Mathematics, 06.07.2019 01:30
Mathematics, 06.07.2019 01:30
Arts, 06.07.2019 01:30
Mathematics, 06.07.2019 01:30
Mathematics, 06.07.2019 01:30
Mathematics, 06.07.2019 01:30
Mathematics, 06.07.2019 01:30