Merge origin/master
Conflicts: web/WEB-INF/AuthentificationJSP.jsp
This commit is contained in:
		@@ -1,62 +1,67 @@
 | 
				
			|||||||
package bdd;
 | 
					package bdd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
Connexion.java
 | 
					Connexion.java
 | 
				
			||||||
Classe permettant d'établir une connexion avec une base de données mySQL
 | 
					Classe permettant d'établir une connexion avec une base de données mySQL
 | 
				
			||||||
*/
 | 
					 */
 | 
				
			||||||
import java.sql.Connection;
 | 
					import java.sql.Connection;
 | 
				
			||||||
import java.sql.DriverManager;
 | 
					import java.sql.DriverManager;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class Connexion {
 | 
					public class Connexion {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static Connection connect;      // Variable de connexion
 | 
					    private static Connection connect;      // Variable de connexion
 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  /**
 | 
					 | 
				
			||||||
   * Constructeur
 | 
					 | 
				
			||||||
   * @param serveur     nom du serveur, localhost si local
 | 
					 | 
				
			||||||
   * @param bdd         nom de la base de données
 | 
					 | 
				
			||||||
   * @param nomUtil     nom utilisateur
 | 
					 | 
				
			||||||
   * @param mdp         mot de passe lié à l'utilisateur
 | 
					 | 
				
			||||||
   */   
 | 
					 | 
				
			||||||
  private Connexion(String serveur, String bdd, String nomUtil, String mdp) {     
 | 
					 | 
				
			||||||
    try {
 | 
					 | 
				
			||||||
      // 1. Chargement du driver
 | 
					 | 
				
			||||||
      //Class.forName("com.mysql.jdbc.Driver");
 | 
					 | 
				
			||||||
      Class.forName("com.mysql.cj.jdbc.Driver");
 | 
					 | 
				
			||||||
      System.out.println("Driver accessible");
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
      // 2. Initialisation des paramètres de connexion
 | 
					 | 
				
			||||||
      String host   = serveur;                              // Serveur de bd
 | 
					 | 
				
			||||||
      String dbname = bdd;                                  // Nom bd
 | 
					 | 
				
			||||||
      String url = "jdbc:mysql://" + host + "/" + dbname;   // url de connexion
 | 
					 | 
				
			||||||
      //url += "?autoReconnect=true";  // Ajout 26/09/2021
 | 
					 | 
				
			||||||
      System.out.println("url : "+url);
 | 
					 | 
				
			||||||
      String user = nomUtil;                                // nom du user
 | 
					 | 
				
			||||||
      System.out.println("nomUtil : "+nomUtil);
 | 
					 | 
				
			||||||
      String passwd = mdp;                                  // mot de passe
 | 
					 | 
				
			||||||
      System.out.println("mdp : "+mdp);
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
      // 3. Connexion
 | 
					 | 
				
			||||||
      connect = (Connection) DriverManager.getConnection(url, user, passwd);
 | 
					 | 
				
			||||||
      System.out.println("Connexion réussie !");      
 | 
					 | 
				
			||||||
           
 | 
					 | 
				
			||||||
    } catch (Exception e) {        
 | 
					 | 
				
			||||||
      e.printStackTrace();
 | 
					 | 
				
			||||||
    }     
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Retourne la connection établie (Création d'une connection si elle n'existe pas)
 | 
					     * Constructeur
 | 
				
			||||||
     * @param serveur  nom du serveur, localhost si local
 | 
					     *
 | 
				
			||||||
 | 
					     * @param serveur nom du serveur, localhost si local
 | 
				
			||||||
 | 
					     * @param bdd nom de la base de données
 | 
				
			||||||
 | 
					     * @param nomUtil nom utilisateur
 | 
				
			||||||
 | 
					     * @param mdp mot de passe lié à l'utilisateur
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private Connexion(String serveur, String bdd, String nomUtil, String mdp) {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            // 1. Chargement du driver
 | 
				
			||||||
 | 
					            //Class.forName("com.mysql.jdbc.Driver");
 | 
				
			||||||
 | 
					            Class.forName("com.mysql.cj.jdbc.Driver");
 | 
				
			||||||
 | 
					            System.out.println("Driver accessible");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 2. Initialisation des paramètres de connexion
 | 
				
			||||||
 | 
					            String host = serveur;                              // Serveur de bd
 | 
				
			||||||
 | 
					            String dbname = bdd;                                  // Nom bd
 | 
				
			||||||
 | 
					            String url = "jdbc:mysql://" + host + "/" + dbname;   // url de connexion
 | 
				
			||||||
 | 
					            //url += "?autoReconnect=true";  // Ajout 26/09/2021
 | 
				
			||||||
 | 
					            System.out.println("url : " + url);
 | 
				
			||||||
 | 
					            String user = nomUtil;                                // nom du user
 | 
				
			||||||
 | 
					            System.out.println("nomUtil : " + nomUtil);
 | 
				
			||||||
 | 
					            String passwd = mdp;                                  // mot de passe
 | 
				
			||||||
 | 
					            System.out.println("mdp : " + mdp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 3. Connexion
 | 
				
			||||||
 | 
					            connect = (Connection) DriverManager.getConnection(url, user, passwd);
 | 
				
			||||||
 | 
					            System.out.println("Connexion réussie !");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
					            e.printStackTrace();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Retourne la connection établie (Création d'une connection si elle
 | 
				
			||||||
 | 
					     * n'existe pas)
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param serveur nom du serveur, localhost si local
 | 
				
			||||||
     * @param bdd nom de la base de données
 | 
					     * @param bdd nom de la base de données
 | 
				
			||||||
     * @param nomUtil nom utilisateur
 | 
					     * @param nomUtil nom utilisateur
 | 
				
			||||||
     * @param mdp mot de passe lié à l'utilisateur
 | 
					     * @param mdp mot de passe lié à l'utilisateur
 | 
				
			||||||
     * @return connection établie
 | 
					     * @return connection établie
 | 
				
			||||||
     */  
 | 
					     */
 | 
				
			||||||
    public static Connection getConnect(String serveur, String bdd, String nomUtil, String mdp) {
 | 
					    public static Connection getConnect(String serveur, String bdd, String nomUtil, String mdp) {
 | 
				
			||||||
        System.out.println("getConnect");
 | 
					        System.out.println("getConnect");
 | 
				
			||||||
        if (connect == null) {
 | 
					        if (connect == null) {
 | 
				
			||||||
            new Connexion(serveur, bdd, nomUtil, mdp);
 | 
					            new Connexion(serveur, bdd, nomUtil, mdp);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return connect;
 | 
					        return connect;
 | 
				
			||||||
    } 
 | 
					    }
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,15 +19,14 @@ import java.util.ArrayList;
 | 
				
			|||||||
 * @author thomas.millot
 | 
					 * @author thomas.millot
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class PompierMysql {
 | 
					public class PompierMysql {
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    private Connection theConnection;
 | 
					    private Connection theConnection;
 | 
				
			||||||
    private Pompier unPompier;
 | 
					    private Pompier unPompier;
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    public PompierMysql()
 | 
					    public PompierMysql() {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        theConnection = Connexion.getConnect("localhost", "sdis29", "admin", "minda");
 | 
					        theConnection = Connexion.getConnect("localhost", "sdis29", "admin", "minda");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    public ArrayList<Pompier> readAll() {
 | 
					    public ArrayList<Pompier> readAll() {
 | 
				
			||||||
        ArrayList<Pompier> lesPompiers = new ArrayList<>();
 | 
					        ArrayList<Pompier> lesPompiers = new ArrayList<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -63,65 +62,67 @@ public class PompierMysql {
 | 
				
			|||||||
            System.out.println("SQLState : " + ex.getSQLState());
 | 
					            System.out.println("SQLState : " + ex.getSQLState());
 | 
				
			||||||
            System.out.println("Code erreur : " + ex.getErrorCode());
 | 
					            System.out.println("Code erreur : " + ex.getErrorCode());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
        return lesPompiers;
 | 
					        return lesPompiers;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Creation du client passé en paramètre dans la table client
 | 
					     * Creation du client passé en paramètre dans la table client Requête non
 | 
				
			||||||
     * Requête non préparée
 | 
					     * préparée
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
     * @param c objet de type Client (sans identifiant)
 | 
					     * @param c objet de type Client (sans identifiant)
 | 
				
			||||||
     * @return int : id du client créé
 | 
					     * @return int : id du client créé
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public int create(Pompier p) {
 | 
					    public int create(Pompier p) {
 | 
				
			||||||
        int id = -1;
 | 
					        int id = -1;
 | 
				
			||||||
        try {           
 | 
					        try {
 | 
				
			||||||
            Statement stmt = theConnection.createStatement();
 | 
					            Statement stmt = theConnection.createStatement();
 | 
				
			||||||
            int status = stmt.executeUpdate(
 | 
					            int status = stmt.executeUpdate(
 | 
				
			||||||
                "INSERT INTO pompier (nom, prenom, statut, mail, login, mdp, adresse, cp, ville, bip, nbGardes, grade, commentaire, dateEnreg, dateModif) "
 | 
					                    "INSERT INTO pompier (nom, prenom, statut, mail, login, mdp, adresse, cp, ville, bip, nbGardes, grade, commentaire, dateEnreg, dateModif) "
 | 
				
			||||||
                + "VALUES ('" + p.getNom() + "', '"
 | 
					                    + "VALUES ('" + p.getNom() + "', '"
 | 
				
			||||||
                                + p.getPrenom() + "', '"
 | 
					                    + p.getPrenom() + "', '"
 | 
				
			||||||
                                + p.getStatut() + "', "
 | 
					                    + p.getStatut() + "', "
 | 
				
			||||||
                                + p.getMail() + ", '"
 | 
					                    + p.getMail() + ", '"
 | 
				
			||||||
                                + p.getLogin() + "', '"
 | 
					                    + p.getLogin() + "', '"
 | 
				
			||||||
                                + p.getMdp() + "', '"
 | 
					                    + p.getMdp() + "', '"
 | 
				
			||||||
                                + p.getAdresse() + "', '"
 | 
					                    + p.getAdresse() + "', '"
 | 
				
			||||||
                                + p.getVille()+ "', '"
 | 
					                    + p.getVille() + "', '"
 | 
				
			||||||
                                + p.getBip()+ "', '"
 | 
					                    + p.getBip() + "', '"
 | 
				
			||||||
                                + p.getNbGardes()+ "', '"
 | 
					                    + p.getNbGardes() + "', '"
 | 
				
			||||||
                                + p.getGrade()+ "', '"
 | 
					                    + p.getGrade() + "', '"
 | 
				
			||||||
                                + p.getCommentaire()+ "', '"
 | 
					                    + p.getCommentaire() + "', '"
 | 
				
			||||||
                                + p.getDateEnreg()+ "', '"
 | 
					                    + p.getDateEnreg() + "', '"
 | 
				
			||||||
                                + p.getDateModif() + "');",
 | 
					                    + p.getDateModif() + "');",
 | 
				
			||||||
                Statement.RETURN_GENERATED_KEYS);
 | 
					                    Statement.RETURN_GENERATED_KEYS);
 | 
				
			||||||
            
 | 
					
 | 
				
			||||||
            // Recherche de l'identifiant du client créé            
 | 
					            // Recherche de l'identifiant du client créé            
 | 
				
			||||||
            if (status > 0) {
 | 
					            if (status > 0) {
 | 
				
			||||||
                ResultSet result = stmt.getGeneratedKeys();
 | 
					                ResultSet result = stmt.getGeneratedKeys();
 | 
				
			||||||
                if (result.first()) {
 | 
					                if (result.first()) {
 | 
				
			||||||
                    id = result.getInt(1);                    
 | 
					                    id = result.getInt(1);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }               
 | 
					            }
 | 
				
			||||||
        } catch (SQLException ex) {
 | 
					        } catch (SQLException ex) {
 | 
				
			||||||
            System.out.println("SQLException : " + ex.getMessage());
 | 
					            System.out.println("SQLException : " + ex.getMessage());
 | 
				
			||||||
            System.out.println("SQLState : " + ex.getSQLState());
 | 
					            System.out.println("SQLState : " + ex.getSQLState());
 | 
				
			||||||
            System.out.println("Code erreur : " + ex.getErrorCode());
 | 
					            System.out.println("Code erreur : " + ex.getErrorCode());
 | 
				
			||||||
        }        
 | 
					        }
 | 
				
			||||||
        return id;
 | 
					        return id;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Creation du client passé en paramètre dans la table client
 | 
					     * Creation du client passé en paramètre dans la table client Requête
 | 
				
			||||||
     * Requête préparée
 | 
					     * préparée
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
     * @param c objet de type Client (sans identifiant)
 | 
					     * @param c objet de type Client (sans identifiant)
 | 
				
			||||||
     * @return int : id du client créé
 | 
					     * @return int : id du client créé
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public int createRP(Pompier p) {
 | 
					    public int createRP(Pompier p) {
 | 
				
			||||||
        int id = -1;
 | 
					        int id = -1;
 | 
				
			||||||
        try {           
 | 
					        try {
 | 
				
			||||||
            PreparedStatement stmt = null;
 | 
					            PreparedStatement stmt = null;
 | 
				
			||||||
            String sql =  "INSERT INTO pompier (nom, prenom, statut, mail, login, mdp, adresse, cp, ville, bip, nbGardes, grade, commentaire, dateEnreg, dateModif) "
 | 
					            String sql = "INSERT INTO pompier (nom, prenom, statut, mail, login, mdp, adresse, cp, ville, bip, nbGardes, grade, commentaire, dateEnreg, dateModif) "
 | 
				
			||||||
                + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
 | 
					                    + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
 | 
				
			||||||
            stmt = theConnection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
 | 
					            stmt = theConnection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
 | 
				
			||||||
            stmt.setString(1, p.getNom());
 | 
					            stmt.setString(1, p.getNom());
 | 
				
			||||||
            stmt.setString(2, p.getPrenom());
 | 
					            stmt.setString(2, p.getPrenom());
 | 
				
			||||||
@@ -139,20 +140,19 @@ public class PompierMysql {
 | 
				
			|||||||
            stmt.setString(14, p.getDateModif());
 | 
					            stmt.setString(14, p.getDateModif());
 | 
				
			||||||
            System.out.println("Requête : " + stmt.toString());
 | 
					            System.out.println("Requête : " + stmt.toString());
 | 
				
			||||||
            int status = stmt.executeUpdate();
 | 
					            int status = stmt.executeUpdate();
 | 
				
			||||||
               
 | 
					
 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            // Recherche de l'identifiant du client créé            
 | 
					            // Recherche de l'identifiant du client créé            
 | 
				
			||||||
            if (status > 0) {
 | 
					            if (status > 0) {
 | 
				
			||||||
                ResultSet result = stmt.getGeneratedKeys();
 | 
					                ResultSet result = stmt.getGeneratedKeys();
 | 
				
			||||||
                if (result.first()) {
 | 
					                if (result.first()) {
 | 
				
			||||||
                    id = result.getInt(1);                    
 | 
					                    id = result.getInt(1);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }               
 | 
					            }
 | 
				
			||||||
        } catch (SQLException ex) {
 | 
					        } catch (SQLException ex) {
 | 
				
			||||||
            System.out.println("SQLException : " + ex.getMessage());
 | 
					            System.out.println("SQLException : " + ex.getMessage());
 | 
				
			||||||
            System.out.println("SQLState : " + ex.getSQLState());
 | 
					            System.out.println("SQLState : " + ex.getSQLState());
 | 
				
			||||||
            System.out.println("Code erreur : " + ex.getErrorCode());
 | 
					            System.out.println("Code erreur : " + ex.getErrorCode());
 | 
				
			||||||
        }        
 | 
					        }
 | 
				
			||||||
        return id;
 | 
					        return id;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,6 +12,7 @@ import java.util.Objects;
 | 
				
			|||||||
 * @author thomas.millot
 | 
					 * @author thomas.millot
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class Pompier {
 | 
					public class Pompier {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private int id;
 | 
					    private int id;
 | 
				
			||||||
    private int idCaserne;
 | 
					    private int idCaserne;
 | 
				
			||||||
    private String nom;
 | 
					    private String nom;
 | 
				
			||||||
@@ -301,6 +302,5 @@ public class Pompier {
 | 
				
			|||||||
    public String toString() {
 | 
					    public String toString() {
 | 
				
			||||||
        return "Pompier{" + "id=" + id + ", idCaserne=" + idCaserne + ", nom=" + nom + ", prenom=" + prenom + ", Statut=" + Statut + ", typePers=" + typePers + ", mail=" + mail + ", login=" + login + ", mdp=" + mdp + ", adresse=" + adresse + ", cp=" + cp + ", ville=" + ville + ", bip=" + bip + ", nbGardes=" + nbGardes + ", grade=" + grade + ", commentaire=" + commentaire + ", dateEnreg=" + dateEnreg + ", dateModif=" + dateModif + '}';
 | 
					        return "Pompier{" + "id=" + id + ", idCaserne=" + idCaserne + ", nom=" + nom + ", prenom=" + prenom + ", Statut=" + Statut + ", typePers=" + typePers + ", mail=" + mail + ", login=" + login + ", mdp=" + mdp + ", adresse=" + adresse + ", cp=" + cp + ", ville=" + ville + ", bip=" + bip + ", nbGardes=" + nbGardes + ", grade=" + grade + ", commentaire=" + commentaire + ", dateEnreg=" + dateEnreg + ", dateModif=" + dateModif + '}';
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,28 +6,30 @@
 | 
				
			|||||||
package com.test.beans;
 | 
					package com.test.beans;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.Objects;
 | 
					import java.util.Objects;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * @author thomas.millot
 | 
					 * @author thomas.millot
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class User {
 | 
					public class User {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private String pseudo;
 | 
					    private String pseudo;
 | 
				
			||||||
    private String mdp;
 | 
					    private String mdp;
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    public User(String pseudo, String mdp){
 | 
					    public User(String pseudo, String mdp) {
 | 
				
			||||||
        this.pseudo = pseudo;
 | 
					        this.pseudo = pseudo;
 | 
				
			||||||
        this.mdp = mdp;        
 | 
					        this.mdp = mdp;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    public String getPseudo(){
 | 
					    public String getPseudo() {
 | 
				
			||||||
        return pseudo;
 | 
					        return pseudo;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    public String getMdp(){
 | 
					    public String getMdp() {
 | 
				
			||||||
        return mdp;
 | 
					        return mdp;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    public void setMdp(){
 | 
					    public void setMdp() {
 | 
				
			||||||
        this.mdp = mdp;
 | 
					        this.mdp = mdp;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,7 +13,7 @@ import jakarta.servlet.http.HttpServletRequest;
 | 
				
			|||||||
 * @author thomas.millot
 | 
					 * @author thomas.millot
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class AuthentifForm {
 | 
					public class AuthentifForm {
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    private String resultat;
 | 
					    private String resultat;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public String getResultat() {
 | 
					    public String getResultat() {
 | 
				
			||||||
@@ -24,20 +24,19 @@ public class AuthentifForm {
 | 
				
			|||||||
        this.resultat = resultat;
 | 
					        this.resultat = resultat;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public boolean controlerAdmin(HttpServletRequest request){
 | 
					    public boolean controlerAdmin(HttpServletRequest request) {
 | 
				
			||||||
        /*  Comparaison entre l'utilisateur admin et un utilisateur créé
 | 
					        /*  Comparaison entre l'utilisateur admin et un utilisateur créé
 | 
				
			||||||
            avec le pseudo et le mdp saisi */
 | 
					            avec le pseudo et le mdp saisi */
 | 
				
			||||||
        User admin = new User("Lovelace", "Ada");
 | 
					        User admin = new User("Lovelace", "Ada");
 | 
				
			||||||
        User userSaisi = new User(  request.getParameter("ztPseudo"),
 | 
					        User userSaisi = new User(request.getParameter("ztPseudo"),
 | 
				
			||||||
                                    request.getParameter("ztMDP"));
 | 
					                request.getParameter("ztMDP"));
 | 
				
			||||||
        boolean isAdmin = userSaisi.equals(admin);
 | 
					        boolean isAdmin = userSaisi.equals(admin);
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
        // Mise à jour de l'attribut resultat
 | 
					        // Mise à jour de l'attribut resultat
 | 
				
			||||||
        setResultat(isAdmin ? "Vous êtes administrateur" : "Vous n'êtes pas administrateur");
 | 
					        setResultat(isAdmin ? "Vous êtes administrateur" : "Vous n'êtes pas administrateur");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return isAdmin;
 | 
					        return isAdmin;
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,9 +15,9 @@ import javax.xml.bind.DatatypeConverter;
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 * @author Dominique_2
 | 
					 * @author Dominique_2
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public abstract class  MD5 {
 | 
					public abstract class MD5 {
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    public static String encode(String uneChaine){
 | 
					    public static String encode(String uneChaine) {
 | 
				
			||||||
        MessageDigest md = null;
 | 
					        MessageDigest md = null;
 | 
				
			||||||
        String myHash = null;
 | 
					        String myHash = null;
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
@@ -31,5 +31,5 @@ public abstract class  MD5 {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        return myHash;
 | 
					        return myHash;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,7 +35,7 @@ public class AuthentifServlet extends HttpServlet {
 | 
				
			|||||||
            out.println("<!DOCTYPE html>");
 | 
					            out.println("<!DOCTYPE html>");
 | 
				
			||||||
            out.println("<html>");
 | 
					            out.println("<html>");
 | 
				
			||||||
            out.println("<head>");
 | 
					            out.println("<head>");
 | 
				
			||||||
            out.println("<title>Servlet AuthentifServlet</title>");            
 | 
					            out.println("<title>Servlet AuthentifServlet</title>");
 | 
				
			||||||
            out.println("</head>");
 | 
					            out.println("</head>");
 | 
				
			||||||
            out.println("<body>");
 | 
					            out.println("<body>");
 | 
				
			||||||
            out.println("<h1>Servlet AuthentifServlet at " + request.getContextPath() + "</h1>");
 | 
					            out.println("<h1>Servlet AuthentifServlet at " + request.getContextPath() + "</h1>");
 | 
				
			||||||
@@ -57,7 +57,7 @@ public class AuthentifServlet extends HttpServlet {
 | 
				
			|||||||
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
 | 
					    protected void doGet(HttpServletRequest request, HttpServletResponse response)
 | 
				
			||||||
            throws ServletException, IOException {
 | 
					            throws ServletException, IOException {
 | 
				
			||||||
        //processRequest(request, response);   
 | 
					        //processRequest(request, response);   
 | 
				
			||||||
        getServletContext().getRequestDispatcher("/WEB-INF/AuthentificationJSP.jsp").forward(request, response); 
 | 
					        getServletContext().getRequestDispatcher("/WEB-INF/AuthentificationJSP.jsp").forward(request, response);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,7 +35,7 @@ public class ModifServlet extends HttpServlet {
 | 
				
			|||||||
            out.println("<!DOCTYPE html>");
 | 
					            out.println("<!DOCTYPE html>");
 | 
				
			||||||
            out.println("<html>");
 | 
					            out.println("<html>");
 | 
				
			||||||
            out.println("<head>");
 | 
					            out.println("<head>");
 | 
				
			||||||
            out.println("<title>Servlet ModifServlet</title>");            
 | 
					            out.println("<title>Servlet ModifServlet</title>");
 | 
				
			||||||
            out.println("</head>");
 | 
					            out.println("</head>");
 | 
				
			||||||
            out.println("<body>");
 | 
					            out.println("<body>");
 | 
				
			||||||
            out.println("<h1>Servlet ModifServlet at " + request.getContextPath() + "</h1>");
 | 
					            out.println("<h1>Servlet ModifServlet at " + request.getContextPath() + "</h1>");
 | 
				
			||||||
@@ -57,7 +57,7 @@ public class ModifServlet extends HttpServlet {
 | 
				
			|||||||
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
 | 
					    protected void doGet(HttpServletRequest request, HttpServletResponse response)
 | 
				
			||||||
            throws ServletException, IOException {
 | 
					            throws ServletException, IOException {
 | 
				
			||||||
        //processRequest(request, response);   
 | 
					        //processRequest(request, response);   
 | 
				
			||||||
        getServletContext().getRequestDispatcher("/WEB-INF/ModifProfilJSP.jsp").forward(request, response); 
 | 
					        getServletContext().getRequestDispatcher("/WEB-INF/ModifProfilJSP.jsp").forward(request, response);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -84,4 +84,4 @@ public class ModifServlet extends HttpServlet {
 | 
				
			|||||||
        return "Short description";
 | 
					        return "Short description";
 | 
				
			||||||
    }// </editor-fold>
 | 
					    }// </editor-fold>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,12 +30,12 @@ public class ProfilServlet extends HttpServlet {
 | 
				
			|||||||
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
 | 
					    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
 | 
				
			||||||
            throws ServletException, IOException {
 | 
					            throws ServletException, IOException {
 | 
				
			||||||
        response.setContentType("text/html;charset=UTF-8");
 | 
					        response.setContentType("text/html;charset=UTF-8");
 | 
				
			||||||
        try ( PrintWriter out = response.getWriter()) {
 | 
					        try ( PrintWriter out = response.getWriter()) 
 | 
				
			||||||
            /* TODO output your page here. You may use following sample code. */
 | 
					        {
 | 
				
			||||||
            out.println("<!DOCTYPE html>");
 | 
					            out.println("<!DOCTYPE html>");
 | 
				
			||||||
            out.println("<html>");
 | 
					            out.println("<html>");
 | 
				
			||||||
            out.println("<head>");
 | 
					            out.println("<head>");
 | 
				
			||||||
            out.println("<title>Servlet ProfilServlet</title>");            
 | 
					            out.println("<title>Servlet Profil</title>");
 | 
				
			||||||
            out.println("</head>");
 | 
					            out.println("</head>");
 | 
				
			||||||
            out.println("<body>");
 | 
					            out.println("<body>");
 | 
				
			||||||
            out.println("<h1>Servlet ProfilServlet at " + request.getContextPath() + "</h1>");
 | 
					            out.println("<h1>Servlet ProfilServlet at " + request.getContextPath() + "</h1>");
 | 
				
			||||||
@@ -57,7 +57,7 @@ public class ProfilServlet extends HttpServlet {
 | 
				
			|||||||
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
 | 
					    protected void doGet(HttpServletRequest request, HttpServletResponse response)
 | 
				
			||||||
            throws ServletException, IOException {
 | 
					            throws ServletException, IOException {
 | 
				
			||||||
        //processRequest(request, response);   
 | 
					        //processRequest(request, response);   
 | 
				
			||||||
        getServletContext().getRequestDispatcher("/WEB-INF/ProfilJSP.jsp").forward(request, response); 
 | 
					        getServletContext().getRequestDispatcher("/WEB-INF/ProfilJSP.jsp").forward(request, response);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -70,7 +70,8 @@ public class ProfilServlet extends HttpServlet {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
 | 
					    protected void doPost(HttpServletRequest request, HttpServletResponse response)
 | 
				
			||||||
            throws ServletException, IOException {
 | 
					            throws ServletException, IOException 
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
        processRequest(request, response);
 | 
					        processRequest(request, response);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -84,4 +85,4 @@ public class ProfilServlet extends HttpServlet {
 | 
				
			|||||||
        return "Short description";
 | 
					        return "Short description";
 | 
				
			||||||
    }// </editor-fold>
 | 
					    }// </editor-fold>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,23 +5,32 @@
 | 
				
			|||||||
--%>
 | 
					--%>
 | 
				
			||||||
<%@include file="jspf/enteteJSPF.jspf" %>
 | 
					<%@include file="jspf/enteteJSPF.jspf" %>
 | 
				
			||||||
<div id="contenu">
 | 
					<div id="contenu">
 | 
				
			||||||
      <h2>Merci de vous identifier pour acceder aux dossiers</h2>
 | 
					    <h2>Merci de vous identifier pour acceder aux dossiers</h2>
 | 
				
			||||||
	<form name="frmIdentification" method="POST" action="">    
 | 
					    <form name="frmIdentification" method="POST" action="Profil">  
 | 
				
			||||||
        <fieldset><legend>Identification utilisateur</legend>
 | 
					        <c:choose>
 | 
				
			||||||
            <br /><br />
 | 
					            <c:when test="${empty param.ztPseudo}">
 | 
				
			||||||
               <label for="nom">Nom du compte</label>
 | 
					                <fieldset><legend>Identification utilisateur</legend>
 | 
				
			||||||
               <input id="login" 	type="text" 	name="login"  size="30" maxlength="45" 	placeholder="Entrez votre nom d'Utilisateur">
 | 
					                    <br /><br />
 | 
				
			||||||
            </p>
 | 
					                    <label for="nom">Nom du compte</label>
 | 
				
			||||||
            <p>
 | 
					                    <input id="login" 	type="text" 	name="login"  size="30" maxlength="45" 	placeholder="Entrez votre nom d'Utilisateur">
 | 
				
			||||||
                <label for="mdp">Mot de passe</label>
 | 
					                    </p>
 | 
				
			||||||
                <input id="mdp" 	type="password"  name="mdp" size="30" 	maxlength="45" 	placeholder="Entrez votre Mot de Passe">
 | 
					                    <p>
 | 
				
			||||||
            </p><br /><br />
 | 
					                        <label for="mdp">Mot de passe</label>
 | 
				
			||||||
                <input type="submit" 	name="valider"		value="Valider">
 | 
					                        <input id="mdp" 	type="password"  name="mdp" size="30" 	maxlength="45" 	placeholder="Entrez votre Mot de Passe">
 | 
				
			||||||
                <input type="reset" 	name="annuler" 		value="Annuler">
 | 
					                    </p><br /><br />
 | 
				
			||||||
            </p>
 | 
					                    <input type="submit" 	name="valider"		value="Valider">
 | 
				
			||||||
        </fieldset>
 | 
					                    <input type="reset" 	name="annuler" 		value="Annuler">
 | 
				
			||||||
	</form>
 | 
					                    </p>
 | 
				
			||||||
    <br /><br />   
 | 
					                </fieldset>
 | 
				
			||||||
    
 | 
					            </c:when>  
 | 
				
			||||||
 | 
					            <c:otherwise>
 | 
				
			||||||
 | 
					                <!--    Si l'utilisateur s'est authentifi<66>,
 | 
				
			||||||
 | 
					                 Affichage du message contenu dans l'objet controlForm de type AuthentifForm -->
 | 
				
			||||||
 | 
					                <p>${controlForm.getResultat()}</p>
 | 
				
			||||||
 | 
					            </c:otherwise>
 | 
				
			||||||
 | 
					        </c:choose>
 | 
				
			||||||
 | 
					    </form>
 | 
				
			||||||
 | 
					    <br /><br/>
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,20 +6,4 @@
 | 
				
			|||||||
<%@include file="jspf/enteteJSPF.jspf" %>
 | 
					<%@include file="jspf/enteteJSPF.jspf" %>
 | 
				
			||||||
<div id="contenu">
 | 
					<div id="contenu">
 | 
				
			||||||
      <h2>Merci de vous identifier pour acceder aux dossiers</h2>
 | 
					      <h2>Merci de vous identifier pour acceder aux dossiers</h2>
 | 
				
			||||||
	<form name="frmIdentification" method="POST" action="Profil">    
 | 
					 | 
				
			||||||
        <fieldset><legend>Identification utilisateur</legend>
 | 
					 | 
				
			||||||
            <br /><br />
 | 
					 | 
				
			||||||
               <label for="nom">Nom du compte</label>
 | 
					 | 
				
			||||||
               <input id="login" 	type="text" 	name="login"  size="30" maxlength="45" 	placeholder="Entrez votre nom d'Utilisateur">
 | 
					 | 
				
			||||||
            </p>
 | 
					 | 
				
			||||||
            <p>
 | 
					 | 
				
			||||||
                <label for="mdp">Mot de passe</label>
 | 
					 | 
				
			||||||
                <input id="mdp" 	type="password"  name="mdp" size="30" 	maxlength="45" 	placeholder="Entrez votre Mot de Passe">
 | 
					 | 
				
			||||||
            </p><br /><br />
 | 
					 | 
				
			||||||
                <input type="submit" 	name="valider"		value="Valider">
 | 
					 | 
				
			||||||
                <input type="reset" 	name="annuler" 		value="Annuler">
 | 
					 | 
				
			||||||
            </p>
 | 
					 | 
				
			||||||
        </fieldset>
 | 
					 | 
				
			||||||
	</form>
 | 
					 | 
				
			||||||
    <br /><br />
 | 
					 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user