Java Netbeans code
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:
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 file:
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 file:
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 file:
Hello, System Admin! As administrator, you have access to the zoo's main computer system. This allows you to monitor users in the system and their roles.
MD5 file:
import java.security.MessageDigest;
public class MD5Digest {
public static void main(String[] args) throws
Exception {
//Copy and paste this section of
code
String original = "letmein";
//Replace "password" with the actual password inputted by the
user
MessageDigest md =
MessageDigest.getInstance("MD5");
md.update(original.getBytes());
byte[] digest = md.digest();
StringBuffer sb = new
StringBuffer();
for (byte b : digest) {
sb.append(String.format("%02x", b & 0xff));
}
//End copy/paste
System.out.println("original:" +
original);
System.out.println("digested:" +
sb.toString()); //sb.toString() is what you'll need to compare
password strings
}
}
Code:
//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("\nLogin");
//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("\t");
// 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.\n");
}
}
//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("\nWelcome Admin");
//Display message
System.out.println("user Press 99 for log out\n");
//Do loop
do
{
//Store value
logOut123 = sc1.nextLine();
}
//Loop
while(!logOut123.equals("99"));
//If value is 99
if(logOut123.equals("99"))
{
//Call method
loginScreenpro();
}
}
}
Java Netbeans code Option 1: Authentication System For security-minded professionals, it is important that only the...
I need help ASAP on this, this is due at midnight PST. This is the current code I have. How can I allow the user to quit. My counting while loop works fine, but I would like it to not keep outputting username if a file was successfully opened. This is what is required. 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...
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...
Create an application programming interface (API) using stored procedures that allows an EMR system developer to work with the database without having to write SQL statements Add user authentication so that only authorized users can access the database Add some form of role-based access control to limit the functions that a user can perform. You should implement at least one use case to demonstrate this capability. For example, you may allow a physician to delete a prescription order, but not...
Question 1 1 point possible (graded) True or False: Because IoT is an ecosystem, IoT Security is not just device security. True False Question 2 1 point possible (graded) When comparing IoT malware to traditional viruses, worms, or spam, which of these statements are true? (Select three) Conventional anti-virus or anti-spam schemes work well for IoT malware detection and prevention. IoT malware has much less user interaction. IoT malware is hard to kill due to lack of direct interface with...
TRUE/FALSE QUESTIONS: Foundations of Information Security and Assurance 1. There is a problem anticipating and testing for all potential types of non-standard inputs that might be exploited by an attacker to subvert a program. 2. Without suitable synchronization of accesses it is possible that values may be corrupted, or changes lost, due to over-lapping access, use, and replacement of shared values. 3. The biggest change of the nature in Windows XP SP2 was to change all anonymous remote procedure call (RPC)...
The discussion: 150 -200 words. Auditing We know that computer security audits are important in business. However, let’s think about the types of audits that need to be performed and the frequency of these audits. Create a timeline that occurs during the fiscal year of audits that should occur and “who” should conduct the audits? Are they internal individuals, system administrators, internal accountants, external accountants, or others? Let me start you: (my timeline is wrong but you should use some...
CASE 8 Unlocking the Secrets of the Apple iPhone in the Name of access the male San Bernardino suspect's iPhone 5c. Cook stated: Antiterrorism We are challenging the FBI's demands with the deepes respect for American democracy and a love of our country. We believe it would be in the best interest of everyone to step back and consider the implications While we believe the FBI's intentions are good, if would be wrong for the w e nt to force...