Advertisement
Guest User

Untitled

a guest
Nov 11th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.19 KB | None | 0 0
  1. package com.emilkraft.tut1;
  2.  
  3. import javax.swing.JOptionPane;
  4.  
  5. public class Authenticator {
  6.    
  7.     public static void main(String args[]) {
  8.         /*
  9.          * Die Strings
  10.          */
  11.         String username = JOptionPane.showInputDialog("Benutzername:");
  12.         String password = JOptionPane.showInputDialog("Passwort:");
  13.         /*
  14.          * If
  15.          * Du musst natürlich nicht so wie ich schreiben!
  16.          * NUR wegen der Übersicht!
  17.          */
  18.         if(
  19.             username != null &&
  20.             password != null &&
  21.             (
  22.                     /*
  23.                      * Die Benutzer mit Passwörtern
  24.                      */
  25.                    
  26.                     //Benutzer1
  27.                     (username.equals("bspname") &&
  28.                      //Passwort1
  29.                      password.equals("bsppassword")) ||
  30.                     //Benutzer2
  31.                     (username.equals("bspname2") &&
  32.                      //Passwort2
  33.                      password.equals("bsppassword2"))
  34.             )
  35.         )
  36.         {
  37.             //Meldung nach richtigem Namen und Passwort
  38.             JOptionPane.showMessageDialog(null, "Bekannter Benutzer! Zugang gewährt!");
  39.         } else {
  40.             //Meldung nach falschem Namen und Passwort
  41.             JOptionPane.showMessageDialog(null, "Unbekannter Benutzer! Zugang verweigert!");
  42.         }
  43.         /*
  44.          * TODO: Eigenen Code hinzufügen
  45.          * z.B. Nach richtigem Namen und Passwort einen JFrame mit Inhalt öffnen (Nur ein Beispiel!)
  46.          */
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement