Compare commits

...

19 Commits

Author SHA1 Message Date
elliass.chelloug
0d1d4385f9 Merge origin/master
Conflicts:
	src/java/bdd/PompierMysql.java
2021-10-22 12:38:08 +02:00
elliass.chelloug
30e988a406 Merge origin/master
Conflicts:
	src/java/bdd/PompierMysql.java
2021-10-21 17:22:42 +02:00
elliass.chelloug
ad2a770dc8 Merge origin/master
Conflicts:
	src/java/bdd/PompierMysql.java
2021-10-21 15:48:00 +02:00
elliass.chelloug
3cfc1f99e4 Merge origin/master
Conflicts:
	src/java/bdd/PompierMysql.java
2021-10-21 14:33:44 +02:00
elliass.chelloug
ff03911709 Merge origin/master 2021-10-21 14:14:07 +02:00
elliass.chelloug
3eafc8b2ee Merge origin/master
Conflicts:
	src/java/bdd/PompierMysql.java
2021-10-21 14:13:56 +02:00
thomas.millot
0ec37013ed Merge origin/master
Conflicts:
	web/WEB-INF/AuthentificationJSP.jsp
2021-10-21 14:13:15 +02:00
elliass.chelloug
e27f948c2a Merge origin/master
Conflicts:
	src/java/bdd/PompierMysql.java
	src/java/com/test/servlets/AuthentifServlet.java
	web/WEB-INF/AuthentificationJSP.jsp
	web/WEB-INF/ProfilJSP.jsp
2021-10-20 11:50:22 +02:00
thomas.millot
1a26976d0a Merge origin/master
Conflicts:
	web/WEB-INF/AuthentificationJSP.jsp
2021-10-20 11:49:53 +02:00
elliass.chelloug
c7df279eab Merge origin/master
Conflicts:
	web/WEB-INF/AuthentificationJSP.jsp
	web/WEB-INF/ProfilJSP.jsp
2021-10-20 11:46:39 +02:00
elliass.chelloug
1e8257677c Merge origin/master
Conflicts:
	web/WEB-INF/AuthentificationJSP.jsp
	web/WEB-INF/ProfilJSP.jsp
2021-10-20 11:34:47 +02:00
thomas.millot
e5fa228860 Merge origin/master
Conflicts:
	web/WEB-INF/AuthentificationJSP.jsp
2021-10-20 11:11:29 +02:00
elliass.chelloug
05e4eb1b4c Merge origin/master
Conflicts:
	web/WEB-INF/AuthentificationJSP.jsp
	web/WEB-INF/ProfilJSP.jsp
2021-10-19 09:50:40 +02:00
thomas.millot
2d81cde4a8 Merge origin/master
Conflicts:
	web/WEB-INF/AuthentificationJSP.jsp
2021-10-19 09:45:57 +02:00
thomas.millot
94db0015ee Merge origin/master
Conflicts:
	web/WEB-INF/AuthentificationJSP.jsp
2021-10-19 09:29:19 +02:00
elliass.chelloug
fa6c0561f6 Merge origin/master
Conflicts:
	web/WEB-INF/AuthentificationJSP.jsp
	web/WEB-INF/ProfilJSP.jsp
2021-10-19 09:10:28 +02:00
elliass.chelloug
e58f60e5ec Merge origin/master
Conflicts:
	web/WEB-INF/AuthentificationJSP.jsp
2021-10-19 08:56:38 +02:00
elliass.chelloug
eb07fbaac9 Merge origin/master
Conflicts:
	web/WEB-INF/AuthentificationJSP.jsp
2021-10-19 08:52:08 +02:00
elliass.chelloug
5ebec6b026 Merge origin/master
Conflicts:
	web/WEB-INF/AuthentificationJSP.jsp
2021-10-18 17:22:27 +02:00
11 changed files with 194 additions and 68 deletions

BIN
proj/AP31-Projet1.war Normal file

Binary file not shown.

View File

@@ -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;
}
} }

View File

@@ -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,19 +25,13 @@ public class AuthentifForm {
this.resultat = resultat; this.resultat = resultat;
} }
public boolean controlerAdmin(HttpServletRequest request) { public boolean authentifPompier(HttpServletRequest request)
/* Comparaison entre l'utilisateur admin et un utilisateur créé {
avec le pseudo et le mdp saisi */ PompierMysql pms = new PompierMysql();
User admin = new User("Lovelace", "Ada"); boolean reponse = pms.readPompier(request);
User userSaisi = new User(request.getParameter("ztPseudo"), resultat = reponse ?"": "login ou mot de passe incorrect";
request.getParameter("ztMDP")); request.setAttribute("message", resultat);
boolean isAdmin = userSaisi.equals(admin); return reponse;
// Mise à jour de l'attribut resultat
setResultat(isAdmin ? "Vous êtes administrateur" : "Vous n'êtes pas administrateur");
return isAdmin;
} }
} }

View File

@@ -5,31 +5,32 @@
*/ */
package com.test.forms; package com.test.forms;
/**
*
* @author sio
*/
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.xml.bind.DatatypeConverter;
/** public abstract class MD5 {
*
* @author Dominique_2
*/
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;
try { try {
md = MessageDigest.getInstance("MD5"); md = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException ex) { } catch (NoSuchAlgorithmException ex) {
Logger.getLogger(AuthentifForm.class.getName()).log(Level.SEVERE, null, ex); throw new IllegalArgumentException(ex);
} }
md.update(uneChaine.getBytes()); md.update(uneChaine.getBytes());
byte[] digest = md.digest(); byte[] digest = md.digest();
myHash = DatatypeConverter.printHexBinary(digest).toLowerCase(); //myHash = DatatypeConverter.printHexBinary(digest).toLowerCase();
StringBuilder sb = new StringBuilder();
return myHash; for (byte b : digest) {
sb.append(String.format("%02x", b));
}
return sb.toString();
} }
} }

View File

@@ -73,16 +73,18 @@ public class AuthentifServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) protected void doPost(HttpServletRequest request, HttpServletResponse response)
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
boolean isAdmin = leControle.controlerAdmin(request); if(leControle.authentifPompier(request))
// Création de 2 attributs de requête (isAdmin et leControle) {
request.setAttribute("isAdmin", isAdmin); getServletContext().getRequestDispatcher("/WEB-INF/ProfilJSP.jsp")
request.setAttribute("controlForm", leControle);
// Affichage de la JSP
getServletContext().getRequestDispatcher("/WEB-INF/ProfilJSP.jsp")
.forward(request, response); .forward(request, response);
}
else
{
getServletContext().getRequestDispatcher("/WEB-INF/AuthentificationJSP.jsp")
.forward(request, response);
}
} }
/** /**

View File

@@ -30,8 +30,8 @@ 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>");

View File

@@ -9,10 +9,8 @@
<!-- 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">
<form name="frmIdentification" method="POST" action="Authentif">
<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">
<c:choose>
<c:when test="${empty param.ztPseudo}">
<fieldset><legend>Identification utilisateur</legend> <fieldset><legend>Identification utilisateur</legend>
<br /><br /> <br /><br />
<label for="nom">Nom du compte</label> <label for="nom">Nom du compte</label>
@@ -25,16 +23,9 @@
<input type="submit" name="valider" value="Valider"> <input type="submit" name="valider" value="Valider">
<input type="reset" name="annuler" value="Annuler"> <input type="reset" name="annuler" value="Annuler">
</p> </p>
<p>${message}</p>
</fieldset> </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> </form>
<br /><br/> <br/><br/>
</div> </div>
</html> </html>

View File

@@ -3,15 +3,34 @@
Created on : 18 oct. 2021, 11:10:01 Created on : 18 oct. 2021, 11:10:01
Author : Millot.thomas Author : Millot.thomas
--%> --%>
<%@include file="jspf/enteteJSPF.jspf" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <form name="Profil" method="POST" action="ProfilJSP.jsp">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <table style='border: 0px solid white;'>
<title>JSP Page</title> <tr>
</head> <td style='border :0px;'>
<body> <fieldset><legend>Coordonnées Pompier</legend>
<h1>Hello World!</h1> <table>
</body> <tr><th>Nom : </th><td><input type="text" name="ztNom" size="20" maxlength="30"></td></tr>
<tr><th>Prénom : </th><td><input type="text" name="ztPrenom" size="20" maxlength="30"></td></tr>
<tr><th>Adresse : </th><td><input type="text" name="ztAdr" size="20" maxlength="30"></td></tr>
<tr><th>Ville : </th><td><input type="text"name="ztVille" size="20" maxlength="30"></td></tr>
<tr><th>Code postal : </th><td><input type="text" name="ztCp" size="20" maxlength="30"></td></tr>
<tr><th>Téléphone : </th><td><input type="text" name="ztTel" size="20" maxlength="30"></td></tr>
<tr><th>Mail : </th><td><input type="text" name="ztMail" size="20" maxlength="30"></td></tr>
<tr><th>Statut : </th><td><input readonly type="text" name="ztStatut" size="20" maxlength="30"></td></tr>
<tr><th>Grade : </th><td><input readonly type="text" name="ztGrade" size="20" maxlength="30"></td></tr>
</table>
</fieldset>
<fieldset><legend>Coordonnées Employeur</legend>
<table>
<tr><th>Nom employeur : </th><td><input type="text" name="ztNomEmp" size="20" maxlength="30"></td></tr>
<tr><th>Téléphone employeur : </th><td><input type="text" name="ztTelEmp" size="20" maxlength="30"></td></tr>
<tr><th>Adresse employeur : </th><td><input type="text" name="ztadrEmp" size="20" maxlength="30"></td></tr>
<tr><th>Mail employeur : </th><td><input type="text" name="ztMailEmp" size="20" maxlength="30"></td></tr>
</table>
</fieldset>
<input type="button" name="button" onclick="window.location='http://localhost:8080/AP31-Projet1/Profil'" value="Valider les modification">
</html> </html>

View File

@@ -1,3 +1,32 @@
<div id="contenu"> <%@include file="jspf/enteteJSPF.jspf" %>
<h2>Merci de vous identifier pour acceder aux dossiers</h2> <br /><br />
</div> <form name="frmModifProfil" method="POST" action="ModifProfilJSP.jsp">
<table style='border: 0px solid white;'>
<tr>
<td style='border :0px;'>
<fieldset><legend>Coordonn<6E>es Pompier</legend>
<table>
<tr><th>Nom : </th><td><input type="text" name="ztNom" size="20" maxlength="30"></td></tr>
<tr><th>Pr<50>nom : </th><td><input type="text" name="ztPrenom" size="20" maxlength="30"></td></tr>
<tr><th>Adresse : </th><td><input type="text" name="ztAdr" size="20" maxlength="30"></td></tr>
<tr><th>Ville : </th><td><input type="text"name="ztVille" size="20" maxlength="30"></td></tr>
<tr><th>Code postal : </th><td><input type="text" name="ztCp" size="20" maxlength="30"></td></tr>
<tr><th>T<>l<EFBFBD>phone : </th><td><input type="text" name="ztTel" size="20" maxlength="30"></td></tr>
<tr><th>Mail : </th><td><input type="text" name="ztMail" size="20" maxlength="30"></td></tr>
<tr><th>Statut : </th><td><input readonly type="text" name="ztStatut" size="20" maxlength="30"></td></tr>
<tr><th>Grade : </th><td><input readonly type="text" name="ztGrade" size="20" maxlength="30"></td></tr>
</table>
</fieldset>
<fieldset><legend>Coordonn<6E>es Employeur</legend>
<table>
<tr><th>Nom employeur : </th><td><input type="text" name="ztNomEmp" size="20" maxlength="30"></td></tr>
<tr><th>T<>l<EFBFBD>phone employeur : </th><td><input type="text" name="ztTelEmp" size="20" maxlength="30"></td></tr>
<tr><th>Adresse employeur : </th><td><input type="text" name="ztadrEmp" size="20" maxlength="30"></td></tr>
<tr><th>Mail employeur : </th><td><input type="text" name="ztMailEmp" size="20" maxlength="30"></td></tr>
</table>
</fieldset>
<input type="button" name="button" onclick="window.location='http://localhost:8080/AP31-Projet1/Modif'" value="Modification du profil">
</td>
</tr>
</table>
</form>

View File

@@ -1,10 +1,13 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head> <head>
<<link rel="stylesheet" href="css/newcss.css"/>
<title>SDIS29</title> <title>SDIS29</title>
</head> </head>
<div id="page"> <div id="page">
<div id="entete"> <div id="entete">
<img src="./images/LogoSDIS29.jpg" id="logo" alt="SDIS29" title="SDIS 29" align='left' style="width: 200px; height: 180px" /> <img src="./images/LogoSDIS29.jpg" id="logo" alt="SDIS29" title="SDIS 29" align='left' style="width: 200px; height: 180px";
}/>
<!-- fin de l'ent<6E>te --> <!-- fin de l'ent<6E>te -->

59
web/css/newcss.css Normal file
View File

@@ -0,0 +1,59 @@
/*
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
*/
/*
Created on : 21 oct. 2021, 16:37:16
Author : elliass.chelloug
*/
body
{
background-color: #596b6e;
background-repeat: repeat-x;
margin:0% 0%;
padding : 0.9em;
font-family:"Trebuchet MS",Verdana,Geneva,Arial,Helvetica,sans-serif;
font-size: 0.9em;
}
#contenu
{
border: none;
padding: 2.1em;
background-color: white;
border-left : groove 0.8em #980101;
margin-top : 1.1em;
margin-left: 82px;
min-height:27em;
height:27em;
}
piedForm
{
border-bottom-width : 0.1em;
border-left-width : 0.1em;
border-right-width : 0.1em;
border-top-width : 0em;
border-style : solid;
border-color : #000;
text-align:right ;
width : 95%;
margin-top:0em;
}
form
{
margin-bottom:1em;
}
corpsForm legend
{
font-weight:bold;
font-size:1.2em;
}
corpsForm label
{
float: left;
text-align:right;
width:33%;
margin: 0;
padding: 0 .5em 0 0;
line-height: 1.8;
}