Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Prompt You have assumed the role of managing the technology infrastructure at a

ID: 3598056 • Letter: P

Question

Prompt

You have assumed the role of managing the technology infrastructure at a zoo. You will develop a working program (either an authentication system or a monitoring system) for the zoo designed to follow the specifications outlined in the overview. You will also provide detailed documentation describing your development process. Select from one of the following options as the basis of your program.

Option 1: Authentication System

For security-minded professionals, it is important that only the appropriate people gain access to data in a computer system. This is called authentication. Once users gain entry, it is also important that they only see data related to their role in a computer system. This is called authorization. For the zoo, you will develop an authentication system that manages both authentication and authorization. You have been given a credentials file that contains credential information for authorized users. You have also been given three files, one for each role: zookeeper, veterinarian, and admin. Each role file describes the data the particular role should be authorized to access. Create an authentication system that does all of the following:

• Asks the user for a username

• Asks the user for a password

• Converts the password using a message digest five (MD5) hash

o It is not required that you write the MD5 from scratch. Use the code located in this document and follow the comments in it to perform this operation.

• Checks the credentials against the valid credentials provided in the credentials file

o Use the hashed passwords in the second column; the third column contains the actual passwords for testing and the fourth row contains the role of each user.

• Limits failed attempts to three before notifying the user and exiting the program

• Gives authenticated users access to the correct role file after successful authentication

o The system information stored in the role file should be displayed. For example, if a zookeeper’s credentials is successfully authenticated, then the contents from the zookeeper file will be displayed. If an admin’s credentials is successfully authenticated, then the contents from the admin file will be displayed.

• Allows a user to log out

• Stays on the credential screen until either a successful attempt has been made, three unsuccessful attempts have been made, or a user chooses to exit

You are allowed to add extra roles if you would like to see another type of user added to the system, but you may not remove any of the existing roles.

Credentials file (.txt)

griffin.keyes 108de81c31bf9c622f76876b74e9285f "alphabet soup" zookeeper

rosario.dawson 3e34baa4ee2ff767af8c120a496742b5 "animal doctor" admin

bernie.gorilla a584efafa8f9ea7fe5cf18442f32b07b "secret password" veterinarian

donald.monkey 17b1b7d8a706696ed220bc414f729ad3 "M0nk3y business" zookeeper

jerome.grizzlybear 3adea92111e6307f8f2aae4721e77900 "grizzly1234" veterinarian

bruce.grizzlybear 0d107d09f5bbe40cade3de5c71e9e9b7 "letmein" admin

Zookeeper role file (.txt)

Hello, Zookeeper!

As zookeeper, you have access to all of the animals' information and their daily monitoring logs. This allows you to track their feeding habits, habitat conditions, and general welfare.

Veterinarian role file (.txt)

Hello, Veterinarian!

As veterinarian, you have access to all of the animals' health records. This allows you to view each animal's medical history and current treatments/illnesses (if any), and to maintain a vaccination log.

Admin role file (.txt)

Hello, System Admin!

Explanation / Answer

//Include libraries

import java.io.BufferedReader;

import java.io.FileReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.security.MessageDigest;

import java.security.NoSuchAlgorithmException;

import java.util.Scanner;

import java.io.FileNotFoundException;

//Define a class Secretproc

public class Secretproc

{

     //Define main

     public static void main(String[] args) throws IOException

     {

          //Call method

          loginScreenpro();

     }

     //Define a method

     public static void loginScreenpro()

     {

          //Define string variable

          String gPassword = "";          

          //Declare variables

          int flag123 = 0,attempts123=3;

          //Define reader

BufferedReader br1 = new BufferedReader(new InputStreamReader(System.in));   

          //Display message

          System.out.println(" Login");

          //Try block

          try

          {

              //Do

              do

              {

                   //Decrement value

                   attempts123--;

                   //Display message

                   System.out.println("Enter Username");

                   //Store value

                   String userName = br1.readLine();

                   //Display message

                   System.out.println("Enter Password");

                   //Store value

                   String password = br1.readLine();

                   //Create an instance

MessageDigest md123 = MessageDigest.getInstance("md5");

                   //Update

                   md123.update(password.getBytes());

                   //Call method

                   byte[] bytes12 = md123.digest();

                   //Create an instance

                   StringBuilder lSb1 = new StringBuilder();

                   //Loop

                   for (int k = 0; k < bytes12.length; k++)

                   {

                        //Append

lSb1.append(Integer.toString((bytes12[k] & 0xff) + 0x100, 16).substring(1));

                   }

                   //Generate password

                   gPassword = lSb1.toString();

                   //Declare variable

                   String currentLine;

                   //Define an instance

BufferedReader bin123 = new BufferedReader(new FileReader("Credentials.txt"));

                    //Loop until end of file

                   while ((currentLine = bin123.readLine()) !=                             null)

                   {               

                        //Split each line of file

String[] array123 = currentLine.split(" ");

                        // If user name matches

                        if (array123[0].equals(userName))

                        {

                             //If password matches

                             if (array123[1].equals(gPassword))

                             {                         

                                  //Store file name                            

                                  String x = array123[3];

                                  //Define file reader

                                  BufferedReader br2 = null;

                                  //Declare variable

                                  String strLine1 = "";

                                  //Open file

br2 = new BufferedReader( new FileReader(x+".txt"));

                                  //Loop until file end

while( (strLine1 = br2.readLine()) != null)

                                  {

                                      //Display contents

                                                                                   System.out.println(strLine1);

                                  }

  

                                  //Assign value

                                  flag123 = 1;

                                  //Break

                                  break;

                             }

                        }

                   }

                   //If attempt is 0

                   if(attempts123==0)

                   {

                        //Display message

                        System.out.println("login more times");

                        //Display message

                        System.out.println("Exit...");

                        //Exit

                        System.exit(1);

                   }

           

                   //If flag is 1

                   if (flag123 == 1)

                   {

                        //Call method

                        adminScreenpro();

                        //Break

                        break;

                   }

                   //Otherwise

                   else

                   {

                        //Display message

System.out.println("Invalid Username or Password.");

                        //Display message

                        System.out.println(" try again.");                 

                        //Display message

System.out.println(attempts123+" more attemptes left. ");

                   }

              }

              //Loop

              while(attempts123>0);

          }

          //Define catch

          catch (NoSuchAlgorithmException e1)

          {

              //Trace

              e1.printStackTrace();

          }

          //Define catch block

          catch (IOException e1)

          {

              //Trace

              e1.printStackTrace();

          }

     }

     //Define a method

     public static void adminScreenpro()

     {

          //Declare variable

          String logOut123;

          //Define scanner variable

          Scanner sc1= new Scanner(System.in);

          //Display message

          System.out.println(" Welcome Admin");     

          //Display message

          System.out.println("user Press 99 for log out ");

          //Do loop

          do

          {

              //Store value

              logOut123 = sc1.nextLine();

          }

          //Loop

          while(!logOut123.equals("99"));

          //If value is 99

          if(logOut123.equals("99"))

          {

              //Call method

              loginScreenpro();

          }

     }

}