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
This commit is contained in:
commit
e27f948c2a
BIN
proj/AP31-Projet1.war
Normal file
BIN
proj/AP31-Projet1.war
Normal file
Binary file not shown.
@ -44,8 +44,30 @@ public class PompierMysql {
|
|||||||
System.out.println("Select * FROM pompier WHERE login = '"+userSaisi+"' AND mdp = '"+mdpChiffre+"';");
|
System.out.println("Select * FROM pompier WHERE login = '"+userSaisi+"' AND mdp = '"+mdpChiffre+"';");
|
||||||
stmt = theConnection.createStatement();
|
stmt = theConnection.createStatement();
|
||||||
ResultSet resultQ = null;
|
ResultSet resultQ = null;
|
||||||
resultQ = stmt.executeQuery("Select * FROM pompier WHERE login = '"+userSaisi+"' AND mdp = '"+mdpChiffre+"';");
|
resultQ = stmt.executeQuery("SELECT * FROM pompier");
|
||||||
reponse = resultQ.next();
|
while (resultQ.next()) {
|
||||||
|
unPompier = new Pompier(resultQ.getInt("id"),
|
||||||
|
resultQ.getString("nom"),
|
||||||
|
resultQ.getString("prenom"),
|
||||||
|
resultQ.getString("statut"),
|
||||||
|
resultQ.getString("typePers"),
|
||||||
|
resultQ.getString("mail"),
|
||||||
|
resultQ.getString("login"),
|
||||||
|
resultQ.getString("mdp"),
|
||||||
|
resultQ.getString("adresse"),
|
||||||
|
resultQ.getInt("cp"),
|
||||||
|
resultQ.getString("ville"),
|
||||||
|
resultQ.getInt("bip"),
|
||||||
|
resultQ.getInt("nbGardes"),
|
||||||
|
resultQ.getInt("grade"),
|
||||||
|
resultQ.getString("commentaire"),
|
||||||
|
resultQ.getString("dateEnreg"),
|
||||||
|
resultQ.getString("dateModif"));
|
||||||
|
lesPompiers.add(unPompier);
|
||||||
|
}
|
||||||
|
resultQ.close();
|
||||||
|
stmt.close();
|
||||||
|
//theConnection.close();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
Logger.getLogger(PompierMysql.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(PompierMysql.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
@ -53,4 +75,120 @@ public class PompierMysql {
|
|||||||
return reponse;
|
return reponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creation du client passé en paramètre dans la table client Requête non
|
||||||
|
* préparée
|
||||||
|
*
|
||||||
|
* @param c objet de type Client (sans identifiant)
|
||||||
|
* @return int : id du client créé
|
||||||
|
*/
|
||||||
|
public int create(Pompier p) {
|
||||||
|
int id = -1;
|
||||||
|
try {
|
||||||
|
Statement stmt = theConnection.createStatement();
|
||||||
|
int status = stmt.executeUpdate(
|
||||||
|
"INSERT INTO pompier (nom, prenom, statut, mail, login, mdp, adresse, cp, ville, bip, nbGardes, grade, commentaire, dateEnreg, dateModif) "
|
||||||
|
+ "VALUES ('" + p.getNom() + "', '"
|
||||||
|
+ p.getPrenom() + "', '"
|
||||||
|
+ p.getStatut() + "', "
|
||||||
|
+ p.getMail() + ", '"
|
||||||
|
+ p.getLogin() + "', '"
|
||||||
|
+ p.getMdp() + "', '"
|
||||||
|
+ p.getAdresse() + "', '"
|
||||||
|
+ p.getVille() + "', '"
|
||||||
|
+ p.getBip() + "', '"
|
||||||
|
+ p.getNbGardes() + "', '"
|
||||||
|
+ p.getGrade() + "', '"
|
||||||
|
+ p.getCommentaire() + "', '"
|
||||||
|
+ p.getDateEnreg() + "', '"
|
||||||
|
+ p.getDateModif() + "');",
|
||||||
|
Statement.RETURN_GENERATED_KEYS);
|
||||||
|
|
||||||
|
// Recherche de l'identifiant du client créé
|
||||||
|
if (status > 0) {
|
||||||
|
ResultSet result = stmt.getGeneratedKeys();
|
||||||
|
if (result.first()) {Merge origin/master
|
||||||
|
|
||||||
|
Conflicts:
|
||||||
|
web/WEB-INF/AuthentificationJSP.jsp
|
||||||
|
web/WEB-INF/ProfilJSP.jsp
|
||||||
|
id = result.getInt(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
System.out.println("SQLException : " + ex.getMessage());
|
||||||
|
System.out.println("SQLState : " + ex.getSQLState());
|
||||||
|
System.out.println("Code erreur : " + ex.getErrorCode());
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creation du client passé en paramètre dans la table client Requête
|
||||||
|
* préparée
|
||||||
|
*
|
||||||
|
* @param c objet de type Client (sans identifiant)
|
||||||
|
* @return int : id du client créé
|
||||||
|
*/
|
||||||
|
public int createRP(Pompier p) {
|
||||||
|
int id = -1;
|
||||||
|
try {
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
String sql = "INSERT INTO pompier (nom, prenom, statut, mail, login, mdp, adresse, cp, ville, bip, nbGardes, grade, commentaire, dateEnreg, dateModif) "
|
||||||
|
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
|
||||||
|
stmt = theConnection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
|
||||||
|
stmt.setString(1, p.getNom());
|
||||||
|
stmt.setString(2, p.getPrenom());
|
||||||
|
stmt.setString(3, p.getStatut());
|
||||||
|
stmt.setString(4, p.getMail());
|
||||||
|
stmt.setString(5, p.getLogin());
|
||||||
|
stmt.setString(6, p.getMdp());
|
||||||
|
stmt.setString(7, p.getAdresse());
|
||||||
|
stmt.setString(8, p.getVille());
|
||||||
|
stmt.setInt(9, p.getBip());
|
||||||
|
stmt.setInt(10, p.getNbGardes());
|
||||||
|
stmt.setInt(11, p.getGrade());
|
||||||
|
stmt.setString(12, p.getCommentaire());
|
||||||
|
stmt.setString(13, p.getDateEnreg());
|
||||||
|
stmt.setString(14, p.getDateModif());
|
||||||
|
System.out.println("Requête : " + stmt.toString());
|
||||||
|
int status = stmt.executeUpdate();
|
||||||
|
|
||||||
|
// Recherche de l'identifiant du client créé
|
||||||
|
if (status > 0) {
|
||||||
|
ResultSet result = stmt.getGeneratedKeys();
|
||||||
|
if (result.first()) {
|
||||||
|
id = result.getInt(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
System.out.println("SQLException : " + ex.getMessage());
|
||||||
|
System.out.println("SQLState : " + ex.getSQLState());
|
||||||
|
System.out.println("Code erreur : " + ex.getErrorCode());
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
String isAdmin = leControle.AuthentifPompier(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);
|
.forward(request, response);
|
||||||
|
}
|
||||||
// Affichage de la JSP
|
else
|
||||||
getServletContext().getRequestDispatcher("/WEB-INF/ProfilJSP.jsp")
|
{
|
||||||
|
getServletContext().getRequestDispatcher("/WEB-INF/AuthentificationJSP.jsp")
|
||||||
.forward(request, response);
|
.forward(request, response);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<!-- Affichage du formulaire si l'utilisateur ne s'est pas encore authentifié -->
|
<!-- Affichage du formulaire si l'utilisateur ne s'est pas encore authentifié -->
|
||||||
<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,7 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
</c:when>
|
</c:when>
|
||||||
<c:otherwise>
|
<c:otherwise>
|
||||||
<!-- Si l'utilisateur s'est authentifié,
|
|
||||||
Affichage du message contenu dans l'objet controlForm de type AuthentifForm -->
|
|
||||||
<p>${controlForm.getResultat()}</p>
|
<p>${controlForm.getResultat()}</p>
|
||||||
</c:otherwise>
|
</c:otherwise>
|
||||||
</c:choose>
|
</c:choose>
|
||||||
|
@ -5,15 +5,15 @@
|
|||||||
<td style='border :0px;'>
|
<td style='border :0px;'>
|
||||||
<fieldset><legend>Coordonnées Pompier</legend>
|
<fieldset><legend>Coordonnées Pompier</legend>
|
||||||
<table>
|
<table>
|
||||||
<tr><th>Nom :<input type="text" name="ztNom" size="20" maxlength="30"></th></tr>
|
<tr><th>Nom : <input type="text" name="ztNom" size="20" maxlength="30"></th></tr>
|
||||||
<tr><th>Prénom :<input type="text" name="ztPrenom" size="20" maxlength="30"></th></tr>
|
<tr><th>Prénom : <input type="text" name="ztPrenom" size="20" maxlength="30"></th></tr>
|
||||||
<tr><th>Adresse :<input type="text" name="ztAdr" size="20" maxlength="30"></th></tr>
|
<tr><th>Adresse : <input type="text" name="ztAdr" size="20" maxlength="30"></th></tr>
|
||||||
<tr><th>Ville :<input type="text"name="ztVille" size="20" maxlength="30"></th></tr>
|
<tr><th>Ville : <input type="text"name="ztVille" size="20" maxlength="30"></th></tr>
|
||||||
<tr><th>Code postal :<input type="text" name="ztCp" size="20" maxlength="30"></th></tr>
|
<tr><th>Code postal : <input type="text" name="ztCp" size="20" maxlength="30"></th></tr>
|
||||||
<tr><th>Téléphone :<input type="text" name="ztTel" size="20" maxlength="30"></th></tr>
|
<tr><th>Téléphone : <input type="text" name="ztTel" size="20" maxlength="30"></th></tr>
|
||||||
<tr><th>Mail :<input type="text" name="ztMail" size="20" maxlength="30"></th></tr>
|
<tr><th>Mail : <input type="text" name="ztMail" size="20" maxlength="30"></th></tr>
|
||||||
<tr><th>Statut :<input type="text" name="ztStatut" size="20" maxlength="30"></th></tr>
|
<tr><th>Statut : <input type="text" name="ztStatut" size="20" maxlength="30"></th></tr>
|
||||||
<tr><th>Grade :<input type="text" name="ztGrade" size="20" maxlength="30"></th></tr>
|
<tr><th>Grade : <input type="text" name="ztGrade" size="20" maxlength="30"></th></tr>
|
||||||
</table>
|
</table>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset><legend>Coordonnées Employeur</legend>
|
<fieldset><legend>Coordonnées Employeur</legend>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user