Merge origin/master
Conflicts: web/WEB-INF/AuthentificationJSP.jsp
This commit is contained in:
BIN
proj/AP31-Projet1.war
Normal file
BIN
proj/AP31-Projet1.war
Normal file
Binary file not shown.
@@ -7,12 +7,17 @@ package bdd;
|
|||||||
|
|
||||||
import com.mysql.cj.xdevapi.Client;
|
import com.mysql.cj.xdevapi.Client;
|
||||||
import com.test.beans.Pompier;
|
import com.test.beans.Pompier;
|
||||||
|
import com.test.forms.MD5;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import java.net.http.HttpRequest;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -33,7 +38,7 @@ public class PompierMysql {
|
|||||||
try {
|
try {
|
||||||
Statement stmt = theConnection.createStatement();
|
Statement stmt = theConnection.createStatement();
|
||||||
ResultSet resultQ = null;
|
ResultSet resultQ = null;
|
||||||
resultQ = stmt.executeQuery("SELECT * FROM client");
|
resultQ = stmt.executeQuery("SELECT * FROM pompier");
|
||||||
while (resultQ.next()) {
|
while (resultQ.next()) {
|
||||||
unPompier = new Pompier(resultQ.getInt("id"),
|
unPompier = new Pompier(resultQ.getInt("id"),
|
||||||
resultQ.getString("nom"),
|
resultQ.getString("nom"),
|
||||||
@@ -156,4 +161,26 @@ public class PompierMysql {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean readPompier(HttpServletRequest request) {
|
||||||
|
boolean reponse = false;
|
||||||
|
Statement stmt;
|
||||||
|
String userSaisi = request.getParameter("ztPseudo");
|
||||||
|
String mdpSaisi = request.getParameter("ztMDP");
|
||||||
|
String mdpChiffre = MD5.encode(mdpSaisi);
|
||||||
|
System.out.println("userSaisi : "+ userSaisi);
|
||||||
|
System.out.println("mdpSaisi : "+ mdpChiffre);
|
||||||
|
try {
|
||||||
|
System.out.println("Select * FROM pompier WHERE login = '"+userSaisi+"' AND mdp = '"+mdpChiffre+"';");
|
||||||
|
stmt = theConnection.createStatement();
|
||||||
|
ResultSet resultQ = null;
|
||||||
|
resultQ = stmt.executeQuery("Select * FROM pompier WHERE login = '"+userSaisi+"' AND mdp = '"+mdpChiffre+"';");
|
||||||
|
reponse = resultQ.next();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
Logger.getLogger(PompierMysql.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return reponse;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.test.forms;
|
package com.test.forms;
|
||||||
|
|
||||||
|
import bdd.PompierMysql;
|
||||||
import com.test.beans.User;
|
import com.test.beans.User;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
@@ -24,16 +25,10 @@ public class AuthentifForm {
|
|||||||
this.resultat = resultat;
|
this.resultat = resultat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String AuthentifPompier(HttpServletRequest request) {
|
public boolean authentifPompier(HttpServletRequest request)
|
||||||
|
{
|
||||||
String userSaisi = request.getParameter("ztPseudo");
|
PompierMysql pms = new PompierMysql();
|
||||||
String mdpSaisi = request.getParameter("ztMDP");
|
return pms.readPompier(request);
|
||||||
String mdpChiffre = MD5.encode(mdpSaisi);
|
|
||||||
|
|
||||||
String sql= "Select login, mdp FROM pompier";
|
|
||||||
|
|
||||||
return sql;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,16 +74,18 @@ public class AuthentifServlet extends HttpServlet {
|
|||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
// Création de l'objet leControle de type AuthentifForm
|
// Création de l'objet leControle de type AuthentifForm
|
||||||
AuthentifForm leControle = new AuthentifForm();
|
AuthentifForm leControle = new AuthentifForm();
|
||||||
// Appel de la méthode controlerAdmin
|
// Appel de la méthode authentifPompier
|
||||||
String isAdmin = leControle.AuthentifPompier(request);
|
if(leControle.authentifPompier(request))
|
||||||
// Création de 2 attributs de requête (isAdmin et leControle)
|
{
|
||||||
request.setAttribute("isAdmin", isAdmin);
|
|
||||||
request.setAttribute("controlForm", leControle);
|
|
||||||
|
|
||||||
// Affichage de la JSP
|
|
||||||
getServletContext().getRequestDispatcher("/WEB-INF/ProfilJSP.jsp")
|
getServletContext().getRequestDispatcher("/WEB-INF/ProfilJSP.jsp")
|
||||||
.forward(request, response);
|
.forward(request, response);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getServletContext().getRequestDispatcher("/WEB-INF/AuthentificationJSP.jsp")
|
||||||
|
.forward(request, response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a short description of the servlet.
|
* Returns a short description of the servlet.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<!-- Affichage du formulaire si l'utilisateur ne s'est pas encore authentifi<66> -->
|
<!-- Affichage du formulaire si l'utilisateur ne s'est pas encore authentifi<66> -->
|
||||||
<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">
|
<form name="frmIdentification" method="POST" action="Authentif">
|
||||||
<c:choose>
|
<c:choose>
|
||||||
<c:when test="${empty param.ztPseudo}">
|
<c:when test="${empty param.ztPseudo}">
|
||||||
<fieldset><legend>Identification utilisateur</legend>
|
<fieldset><legend>Identification utilisateur</legend>
|
||||||
@@ -28,8 +28,6 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
</c:when>
|
</c:when>
|
||||||
<c:otherwise>
|
<c:otherwise>
|
||||||
<!-- Si l'utilisateur s'est authentifi<66>,
|
|
||||||
Affichage du message contenu dans l'objet controlForm de type AuthentifForm -->
|
|
||||||
|
|
||||||
<p>${controlForm.getResultat()}</p>
|
<p>${controlForm.getResultat()}</p>
|
||||||
</c:otherwise>
|
</c:otherwise>
|
||||||
|
|||||||
Reference in New Issue
Block a user