Package test.connexion

Source Code of test.connexion.TestConnexion

package test.connexion;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.rmi.RemoteException;

import client.Client;

import profil.Profil;
import serveur.Serveur;
import util.ProfilException;

public class TestConnexion {

  public static void main(String[] args) {
    String login = null;
    String pass = null;
   
    boolean ok = false;
    Profil profil = null;
   
    InputStreamReader lecteur = new InputStreamReader(System.in);
    BufferedReader in = new BufferedReader(lecteur);
   
    try {
      new Serveur();
     
      while (!ok) {
        System.out.print("Login : ");
        login = in.readLine();
 
        System.out.print("Mot de passe : ");
        pass = in.readLine();
       
        try {
          profil = Client.connexion(login, pass);
         
          if (profil == null) {
            System.err.println("Une erreur est survenue durant la tentative de connexion, veuillez réessayer ultérieurement");
          } else {
            System.out.print("Bienvenue ");
            System.out.println(profil.getPrenom() + " " + profil.getNom());
            ok = true;
          }
        } catch (ProfilException e) {
          System.err.println(e.getMessage());
        }
      }
     
      in.close();
      lecteur.close();
      System.exit(0);
    } catch (RemoteException e) {
      System.err.println("Failure : RemoteException\n");
      e.printStackTrace();
      System.exit(1);
    } catch (IOException e) {
      System.err.println("Failure : IOException\n");
      e.printStackTrace();
      System.exit(1);
    }
  }

}
TOP

Related Classes of test.connexion.TestConnexion

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.