Compare commits

...

2 Commits

Author SHA1 Message Date
clementine.desrucques
3a4053e079 2021-10-18 15:29:09 +02:00
clementine.desrucques
2508fb3386 2021-10-18 15:10:00 +02:00
9 changed files with 320 additions and 8 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/build/
/dist/

View File

@ -1,7 +1,7 @@
<<<<<<< HEAD <<<<<<< HEAD
build.xml.data.CRC32=a917c93e build.xml.data.CRC32=a917c93e
======= =======
build.xml.data.CRC32=f1fb520c build.xml.data.CRC32=4025e2d7
>>>>>>> origin/master >>>>>>> origin/master
build.xml.script.CRC32=6d072c1a build.xml.script.CRC32=6d072c1a
build.xml.stylesheet.CRC32=1707db4f@1.86.0.1 build.xml.stylesheet.CRC32=1707db4f@1.86.0.1
@ -11,7 +11,7 @@ build.xml.stylesheet.CRC32=1707db4f@1.86.0.1
nbproject/build-impl.xml.data.CRC32=a917c93e nbproject/build-impl.xml.data.CRC32=a917c93e
nbproject/build-impl.xml.script.CRC32=33be3f4b nbproject/build-impl.xml.script.CRC32=33be3f4b
======= =======
nbproject/build-impl.xml.data.CRC32=f1fb520c nbproject/build-impl.xml.data.CRC32=4025e2d7
nbproject/build-impl.xml.script.CRC32=bba0324b nbproject/build-impl.xml.script.CRC32=bba0324b
>>>>>>> origin/master >>>>>>> origin/master
nbproject/build-impl.xml.stylesheet.CRC32=334708a0@1.86.0.1 nbproject/build-impl.xml.stylesheet.CRC32=334708a0@1.86.0.1

View File

@ -84,7 +84,6 @@ javadoc.use=true
javadoc.version=false javadoc.version=false
javadoc.windowtitle= javadoc.windowtitle=
lib.dir=${web.docbase.dir}/WEB-INF/lib lib.dir=${web.docbase.dir}/WEB-INF/lib
no.dependencies=false
persistence.xml.dir=${conf.dir} persistence.xml.dir=${conf.dir}
platform.active=default_platform platform.active=default_platform
resource.dir=setup resource.dir=setup

View File

@ -24,10 +24,10 @@
</web-module-libraries> </web-module-libraries>
<web-module-additional-libraries/> <web-module-additional-libraries/>
<source-roots> <source-roots>
<root id="src.dir" name="Source Packages"/> <root id="src.dir"/>
</source-roots> </source-roots>
<test-roots> <test-roots>
<root id="test.src.dir" name="Test Packages"/> <root id="test.src.dir"/>
</test-roots> </test-roots>
</data> </data>
</configuration> </configuration>

View File

@ -0,0 +1,232 @@
/*
* 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.
*/
package com.test.beans;
import java.util.Objects;
/**
*
* @author clementine.desrucques
*/
public class Pompier {
private int id;
private int idCaserne;
private String nom;
private String prenom;
private int statut;
private String mail;
private String login;
private String mdp;
private int adrNo;
private String adrRue;
private String adrCP;
private String adrVille;
private int grade;
public Pompier(int idCaserne, String nom, String prenom, int statut, String mail, String login, String mdp, int adrNo, String adrRue, String adrCP, String adrVille, int grade) {
this.idCaserne = idCaserne;
this.nom = nom;
this.prenom = prenom;
this.statut = statut;
this.mail = mail;
this.login = login;
this.mdp = mdp;
this.adrNo = adrNo;
this.adrRue = adrRue;
this.adrCP = adrCP;
this.adrVille = adrVille;
this.grade = grade;
}
public Pompier(int id, int idCaserne, String nom, String prenom, int statut, String mail, String login, String mdp, int adrNo, String adrRue, String adrCP, String adrVille, int grade) {
this(idCaserne, nom, prenom, statut, mail, login, mdp, adrNo, adrRue, adrCP, adrVille, grade);
this.id = id;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getIdCaserne() {
return idCaserne;
}
public void setIdCaserne(int idCaserne) {
this.idCaserne = idCaserne;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public String getPrenom() {
return prenom;
}
public void setPrenom(String prenom) {
this.prenom = prenom;
}
public int getStatut() {
return statut;
}
public void setStatut(int statut) {
this.statut = statut;
}
public String getMail() {
return mail;
}
public void setMail(String mail) {
this.mail = mail;
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public String getMdp() {
return mdp;
}
public void setMdp(String mdp) {
this.mdp = mdp;
}
public int getAdrNo() {
return adrNo;
}
public void setAdrNo(int adrNo) {
this.adrNo = adrNo;
}
public String getAdrRue() {
return adrRue;
}
public void setAdrRue(String adrRue) {
this.adrRue = adrRue;
}
public String getAdrCP() {
return adrCP;
}
public void setAdrCP(String adrCP) {
this.adrCP = adrCP;
}
public String getAdrVille() {
return adrVille;
}
public void setAdrVille(String adrVille) {
this.adrVille = adrVille;
}
public int getGrade() {
return grade;
}
public void setGrade(int grade) {
this.grade = grade;
}
@Override
public int hashCode() {
int hash = 7;
hash = 29 * hash + this.id;
hash = 29 * hash + this.idCaserne;
hash = 29 * hash + Objects.hashCode(this.nom);
hash = 29 * hash + Objects.hashCode(this.prenom);
hash = 29 * hash + this.statut;
hash = 29 * hash + Objects.hashCode(this.mail);
hash = 29 * hash + Objects.hashCode(this.login);
hash = 29 * hash + Objects.hashCode(this.mdp);
hash = 29 * hash + this.adrNo;
hash = 29 * hash + Objects.hashCode(this.adrRue);
hash = 29 * hash + Objects.hashCode(this.adrCP);
hash = 29 * hash + Objects.hashCode(this.adrVille);
hash = 29 * hash + this.grade;
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Pompier other = (Pompier) obj;
if (this.id != other.id) {
return false;
}
if (this.idCaserne != other.idCaserne) {
return false;
}
if (this.statut != other.statut) {
return false;
}
if (this.adrNo != other.adrNo) {
return false;
}
if (this.grade != other.grade) {
return false;
}
if (!Objects.equals(this.nom, other.nom)) {
return false;
}
if (!Objects.equals(this.prenom, other.prenom)) {
return false;
}
if (!Objects.equals(this.mail, other.mail)) {
return false;
}
if (!Objects.equals(this.login, other.login)) {
return false;
}
if (!Objects.equals(this.mdp, other.mdp)) {
return false;
}
if (!Objects.equals(this.adrRue, other.adrRue)) {
return false;
}
if (!Objects.equals(this.adrCP, other.adrCP)) {
return false;
}
if (!Objects.equals(this.adrVille, other.adrVille)) {
return false;
}
return true;
}
@Override
public String toString() {
return "Pompier{" + "id=" + id + ", idCaserne=" + idCaserne + ", nom=" + nom + ", prenom=" + prenom + ", statut=" + statut + ", mail=" + mail + ", login=" + login + ", mdp=" + mdp + ", adrNo=" + adrNo + ", adrRue=" + adrRue + ", adrCP=" + adrCP + ", adrVille=" + adrVille + ", grade=" + grade + '}';
}
}

View File

@ -0,0 +1,71 @@
/*
* 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.
*/
package com.test.forms;
import com.mysql.cj.util.StringUtils;
import com.test.beans.Pompier;
import jakarta.servlet.http.HttpServletRequest;
import java.util.Enumeration;
/**
*
* @author clementine.desrucques
*/
public class NouveauPompForm {
String message="";
public int verifNouveauClient(HttpServletRequest request) {
// Contrôle du no de rue qui doit être numérique
String noRueString = request.getParameter("ztNoRue");
boolean isNumeric = StringUtils.isStrictlyNumeric(noRueString);
if (!isNumeric) {
message = "Le no de rue doit être numérique";
return -1;
}
int noRue = Integer.parseInt(noRueString);
// Contrôle car "<" dans les zones de texte
//String [] lesSaisies = request.getParameterValues(noRueString); // Valeurs saisies
Enumeration lesNoms = request.getParameterNames();
int erreur = 0;
while (erreur ==0 && lesNoms.hasMoreElements()) {
Object paramObjet=lesNoms.nextElement();
String param=(String)paramObjet;
String value=request.getParameter(param);
if (value.contains("<")) {
message = "Veullez recommencer votre saisie, une anomalie sur une zone de saisie a été détectée ";
erreur=1;
}
}
if (erreur > 0) return -1;
// Creation d'un objet de type Client avec les données transmises
Pompier unPompier = new Pompier(request.getParameter("idCaserne"),
request.getParameter("ztNom"),
request.getParameter("ztPrenom"),
request.getParameter("statut"),
request.getParameter("mail"),
request.getParameter("login"),
request.getParameter("ztMDP"),
noRue,
request.getParameter("ztRue"),
request.getParameter("ztCP"),
request.getParameter("ztVille"),
request.getParameter("grade"));
ClientMysql cm = new ClientMysql();
int idClient = cm.createRP(unPompier); // Requête préparée
if (idClient == -1) {
message = "Erreur lors de la création du client";
}
return idClient;
}
public String getMessage() {
return message;
}
}

View File

@ -1,2 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Context path="/ProjetSDIS29_2"/> <Context path="/ProjetSDIS29_2/Authentification"/>

View File

@ -8,14 +8,14 @@
<%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page contentType="text/html" pageEncoding="UTF-8"%>
<!-- Message de bienvenue personnalisé --> <!-- Message de bienvenue personnalisé -->
<p>Bienvenue <c:out value="${param.ztPseudo}" /> sur la nouvelle application de gestion des clients</p> <p>Bienvenue <c:out value="${param.ztPseudo}" /></p>
${empty param.ztPseudo ? "Veuillez vous authentifier" : "Authentification réussie"} ${empty param.ztPseudo ? "Veuillez vous authentifier" : "Authentification réussie"}
<!-- Affichage du formulaire si l'utilisateur ne s'est pas encore authentifié --> <!-- Affichage du formulaire si l'utilisateur ne s'est pas encore authentifié -->
<c:choose> <c:choose>
<c:when test="${empty param.ztPseudo}"> <c:when test="${empty param.ztPseudo}">
<fieldset> <fieldset>
<legend>Authentification</legend> <legend>Authentification</legend>
<form method="POST" action="Accueil"> <form method="POST" action="Authentification">
<input type="text" name="ztPseudo" placeholder="Pseudo" /><br /><!-- comment --> <input type="text" name="ztPseudo" placeholder="Pseudo" /><br /><!-- comment -->
<input type="password" name="ztMDP" placeholder="Mot de passe" /><br /><br /> <input type="password" name="ztMDP" placeholder="Mot de passe" /><br /><br />
<input type="submit" value="Valider" /> <input type="submit" value="Valider" />

View File

@ -8,6 +8,10 @@
<servlet-name>ChefCaserneServlet</servlet-name> <servlet-name>ChefCaserneServlet</servlet-name>
<servlet-class>com.test.servlets.ChefCaserneServlet</servlet-class> <servlet-class>com.test.servlets.ChefCaserneServlet</servlet-class>
</servlet> </servlet>
<servlet>
<servlet-name>AuthentifServlet</servlet-name>
<servlet-class>com.test.servlets.AuthentifServlet</servlet-class>
</servlet>
<servlet-mapping> <servlet-mapping>
<servlet-name>PompierServlet</servlet-name> <servlet-name>PompierServlet</servlet-name>
<url-pattern>/PompierServlet</url-pattern> <url-pattern>/PompierServlet</url-pattern>
@ -16,6 +20,10 @@
<servlet-name>ChefCaserneServlet</servlet-name> <servlet-name>ChefCaserneServlet</servlet-name>
<url-pattern>/ChefCaserneServlet</url-pattern> <url-pattern>/ChefCaserneServlet</url-pattern>
</servlet-mapping> </servlet-mapping>
<servlet-mapping>
<servlet-name>AuthentifServlet</servlet-name>
<url-pattern>/Authentification</url-pattern>
</servlet-mapping>
<session-config> <session-config>
<session-timeout> <session-timeout>
30 30