Advertisement
Guest User

Untitled

a guest
Jun 21st, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.62 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.InputStreamReader;
  3. import java.security.MessageDigest;
  4. import java.util.HashMap;
  5. import java.util.Map;
  6. import java.util.Scanner;
  7.  
  8. package logincredentials;
  9. public class LoginCredentials {
  10. public static void LoginCredentials(String original) throws Exception {
  11.         MessageDigest md = MessageDigest.getInstance("MD5");
  12.         md.update(original.getBytes());
  13.         byte[] digest = md.digest();
  14.          
  15.         StringBuffer sb = new StringBuffer();
  16.         for (byte b : digest) {661
  17.             sb.append(String.format("%02x", b & 0xff));
  18.         }
  19.         return;
  20.     }
  21. }
  22. /**
  23.  *
  24.  * @author Harrison
  25.  */
  26.  
  27. public class Authentication {
  28.  
  29.     public static void main(String[] args) throws Exception {
  30.         Map<String, String> credentials = new HashMap<>();
  31.         credentials.put("griffin.keyes", "108de81c31bf9c622f76876b74e9285f");
  32.         credentials.put("rosario.dawson", "3e34baa4ee2ff767af8c120a496742b5");
  33.         credentials.put("bernie.gorilla", "a584efafa8f9ea7fe5cf18442f32b07b");
  34.         credentials.put("donald.monkey", "17b1b7d8a706696ed220bc414f729ad3");
  35.         credentials.put("jerome.grizzlybear",    "3adea92111e6307f8f2aae4721e77900");
  36.         credentials.put("bruce.grizzlybear", "0d107d09f5bbe40cade3de5c71e9e9b7");
  37.  
  38.          
  39.         boolean success = false;
  40.         BufferedReader scnr = new BufferedReader(new InputStreamReader(System.in));
  41.         String userName = null;
  42.      
  43.     for (int i = 0; i < 3; ++i){
  44.         System.out.println("Enter username:");
  45.         userName = scnr.readLine();
  46.         System.out.println("Enter password:");
  47.         String password1 = scnr.readLine();
  48.         }
  49.     String hash = credentials.get(userName);
  50.         String password1;
  51.         String zookeeper     = "griffin.keyes";
  52.         String zookeeper1    = "donald.monkey";
  53.         String veterinarian  = "bernie.gorilla";
  54.         String veterinarian1 = "jerome.grizzlybear";
  55.         String Admin         = "rosario.dawson";
  56.         String Admin1        = "bruce.grizzlybear";
  57.         String password;
  58.  
  59.          
  60.       if (userName.equals(zookeeper)) {                        
  61.             System.out.println("Please enter password");
  62.             System.out.println();
  63.              
  64.              
  65.             System.out.println("Hello, Zookeeper!\n" +
  66.                     "\n" + "As zookeeper, you have access to all of the"
  67.                     + " animals'" + " information and their" + " daily"
  68.                     + " monitoring logs. This " + "allows you to track their "
  69.                     + "feeding habits, habitat conditions, and general welfare.");
  70.             System.out.println();
  71.         }
  72.          
  73.         if (userName.equals(zookeeper1)) {
  74.             System.out.println("Please enter password");
  75.             System.out.println();
  76.              
  77.             System.out.println("Hello, Zookeeper!\n" +
  78.                     "\n" + "As zookeeper, you have access to all of the"
  79.                     + " animals'" + " information and their" + " daily"
  80.                     + " monitoring logs. This " + "allows you to track their "
  81.                     + "feeding habits, habitat conditions, and general welfare.");
  82.             System.out.println();
  83.         }
  84.          
  85.         if (userName.equals(veterinarian)) {
  86.             System.out.println("Please enter password");
  87.             System.out.println();
  88.              
  89.             System.out.println("Hello, Veterinarian!\n" + "\n" + "As "
  90.                     + "veterinarian, you have access to all of the animals'"
  91.                     + " health records. This allows you to view each animal's "
  92.                     + "medical history and current treatments/illnesses "
  93.                     + "(if any), and to maintain a vaccination log.");
  94.             System.out.println();
  95.         }
  96.          
  97.         if (userName.equals(veterinarian1)) {
  98.             System.out.println("Please enter password");
  99.             System.out.println();
  100.              
  101.             System.out.println("Hello, Veterinarian!\n" + "\n" + "As "
  102.                     + "veterinarian, you have access to all of the animals'"
  103.                     + " health records. This allows you to view each animal's "
  104.                     + "medical history and current treatments/illnesses "
  105.                     + "(if any), and to maintain a vaccination log.");
  106.             System.out.println();
  107.         }
  108.          
  109.         if (userName.equals(Admin)) {
  110.             System.out.println("Please enter password");
  111.             System.out.println();
  112.              
  113.             System.out.println("Hello, System Admin!\n" + "\n" + "As"
  114.                     + " administrator, you have access to the zoo's main "
  115.                     + "computer system.  This allows you to monitor users in "
  116.                     + "the system and their roles.");
  117.             System.out.println();
  118.         }
  119.          
  120.         if (userName.equals(Admin1)) {
  121.             System.out.println("Please enter password");
  122.             System.out.println();
  123.              
  124.             System.out.println("Hello, System Admin!\n" + "\n" + "As"
  125.                     + " administrator, you have access to the zoo's main "
  126.                     + "computer system.  This allows you to monitor users in "
  127.                     + "the system and their roles.");
  128.             System.out.println();
  129.         }
  130.          
  131.         else {
  132.             System.out.println("Please enter correct login information!");                    
  133.                  
  134.         }
  135.  
  136.          
  137.     }
  138. }
  139.     public static void main(String[] args) {
  140.         // TODO code application logic here
  141.     }
  142.    
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement