ajout des fichers fonctionnels pour l'authentification
This commit is contained in:
parent
53fe3c3dea
commit
900424f337
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/nbproject/private/
|
@ -982,10 +982,19 @@ exists or setup the property manually. For example like this:
|
||||
</target>
|
||||
<target depends="init,compile,compile-jsps,-pre-dist,-do-dist-with-manifest,-do-dist-without-manifest" name="do-dist"/>
|
||||
<target depends="init" if="dist.ear.dir" name="library-inclusion-in-manifest">
|
||||
<copyfiles files="${file.reference.commons-lang3-3.17.0.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
|
||||
<copyfiles files="${file.reference.jakarta.servlet.jsp.jstl-2.0.0.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
|
||||
<copyfiles files="${file.reference.jakarta.servlet.jsp.jstl-api-2.0.0.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
|
||||
<copyfiles files="${file.reference.mysql-connector-java-8.0.23.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
|
||||
<mkdir dir="${build.web.dir}/META-INF"/>
|
||||
<manifest file="${build.web.dir}/META-INF/MANIFEST.MF" mode="update"/>
|
||||
</target>
|
||||
<target depends="init" name="library-inclusion-in-archive" unless="dist.ear.dir"/>
|
||||
<target depends="init" name="library-inclusion-in-archive" unless="dist.ear.dir">
|
||||
<copyfiles files="${file.reference.commons-lang3-3.17.0.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
|
||||
<copyfiles files="${file.reference.jakarta.servlet.jsp.jstl-2.0.0.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
|
||||
<copyfiles files="${file.reference.jakarta.servlet.jsp.jstl-api-2.0.0.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
|
||||
<copyfiles files="${file.reference.mysql-connector-java-8.0.23.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
|
||||
</target>
|
||||
<target depends="init" if="dist.ear.dir" name="-clean-webinf-lib">
|
||||
<delete dir="${build.web.dir}/WEB-INF/lib"/>
|
||||
</target>
|
||||
|
@ -1,8 +1,8 @@
|
||||
build.xml.data.CRC32=b7dbe5f7
|
||||
build.xml.data.CRC32=09107be5
|
||||
build.xml.script.CRC32=14676051
|
||||
build.xml.stylesheet.CRC32=1707db4f@1.98.0.1
|
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||
nbproject/build-impl.xml.data.CRC32=b7dbe5f7
|
||||
nbproject/build-impl.xml.script.CRC32=ff0143c9
|
||||
nbproject/build-impl.xml.data.CRC32=09107be5
|
||||
nbproject/build-impl.xml.script.CRC32=ee796d33
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=334708a0@1.98.0.1
|
||||
|
@ -26,15 +26,23 @@ dist.ear.war=${dist.dir}/${war.ear.name}
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
dist.war=${dist.dir}/${war.name}
|
||||
excludes=
|
||||
file.reference.commons-lang3-3.17.0.jar=C:\\Program Files\\Apache Software Foundation\\Tomcat 10.1\\drivers\\commons-lang3-3.17.0.jar
|
||||
file.reference.jakarta.servlet.jsp.jstl-2.0.0.jar=C:\\Program Files\\Apache Software Foundation\\Tomcat 10.1\\drivers\\jakarta.servlet.jsp.jstl-2.0.0.jar
|
||||
file.reference.jakarta.servlet.jsp.jstl-api-2.0.0.jar=C:\\Program Files\\Apache Software Foundation\\Tomcat 10.1\\drivers\\jakarta.servlet.jsp.jstl-api-2.0.0.jar
|
||||
file.reference.mysql-connector-java-8.0.23.jar=C:\\Program Files\\Apache Software Foundation\\Tomcat 10.1\\drivers\\mysql-connector-java-8.0.23.jar
|
||||
includes=**
|
||||
j2ee.compile.on.save=true
|
||||
j2ee.copy.static.files.on.save=true
|
||||
j2ee.deploy.on.save=true
|
||||
j2ee.platform=10-web
|
||||
j2ee.platform.classpath=${j2ee.server.home}/bin/tomcat-juli.jar:${j2ee.server.home}/lib/annotations-api.jar:${j2ee.server.home}/lib/catalina-ant.jar:${j2ee.server.home}/lib/catalina-ha.jar:${j2ee.server.home}/lib/catalina-ssi.jar:${j2ee.server.home}/lib/catalina-storeconfig.jar:${j2ee.server.home}/lib/catalina-tribes.jar:${j2ee.server.home}/lib/catalina.jar:${j2ee.server.home}/lib/ecj-4.27.jar:${j2ee.server.home}/lib/el-api.jar:${j2ee.server.home}/lib/jakartaee-migration-1.0.8-shaded.jar:${j2ee.server.home}/lib/jasper-el.jar:${j2ee.server.home}/lib/jasper.jar:${j2ee.server.home}/lib/jaspic-api.jar:${j2ee.server.home}/lib/jsp-api.jar:${j2ee.server.home}/lib/servlet-api.jar:${j2ee.server.home}/lib/tomcat-api.jar:${j2ee.server.home}/lib/tomcat-coyote-ffm.jar:${j2ee.server.home}/lib/tomcat-coyote.jar:${j2ee.server.home}/lib/tomcat-dbcp.jar:${j2ee.server.home}/lib/tomcat-i18n-cs.jar:${j2ee.server.home}/lib/tomcat-i18n-de.jar:${j2ee.server.home}/lib/tomcat-i18n-es.jar:${j2ee.server.home}/lib/tomcat-i18n-fr.jar:${j2ee.server.home}/lib/tomcat-i18n-ja.jar:${j2ee.server.home}/lib/tomcat-i18n-ko.jar:${j2ee.server.home}/lib/tomcat-i18n-pt-BR.jar:${j2ee.server.home}/lib/tomcat-i18n-ru.jar:${j2ee.server.home}/lib/tomcat-i18n-zh-CN.jar:${j2ee.server.home}/lib/tomcat-jdbc.jar:${j2ee.server.home}/lib/tomcat-jni.jar:${j2ee.server.home}/lib/tomcat-util-scan.jar:${j2ee.server.home}/lib/tomcat-util.jar:${j2ee.server.home}/lib/tomcat-websocket.jar:${j2ee.server.home}/lib/websocket-api.jar:${j2ee.server.home}/lib/websocket-client-api.jar
|
||||
j2ee.platform.classpath=${j2ee.server.home}/bin/tomcat-juli.jar:${j2ee.server.home}/lib/annotations-api.jar:${j2ee.server.home}/lib/catalina-ant.jar:${j2ee.server.home}/lib/catalina-ha.jar:${j2ee.server.home}/lib/catalina-ssi.jar:${j2ee.server.home}/lib/catalina-storeconfig.jar:${j2ee.server.home}/lib/catalina-tribes.jar:${j2ee.server.home}/lib/catalina.jar:${j2ee.server.home}/lib/ecj-4.27.jar:${j2ee.server.home}/lib/el-api.jar:${j2ee.server.home}/lib/jakartaee-migration-1.0.8-shaded.jar:${j2ee.server.home}/lib/jasper-el.jar:${j2ee.server.home}/lib/jasper.jar:${j2ee.server.home}/lib/jaspic-api.jar:${j2ee.server.home}/lib/jsp-api.jar:${j2ee.server.home}/lib/mysql-connector-java-8.0.23.jar:${j2ee.server.home}/lib/servlet-api.jar:${j2ee.server.home}/lib/tomcat-api.jar:${j2ee.server.home}/lib/tomcat-coyote-ffm.jar:${j2ee.server.home}/lib/tomcat-coyote.jar:${j2ee.server.home}/lib/tomcat-dbcp.jar:${j2ee.server.home}/lib/tomcat-i18n-cs.jar:${j2ee.server.home}/lib/tomcat-i18n-de.jar:${j2ee.server.home}/lib/tomcat-i18n-es.jar:${j2ee.server.home}/lib/tomcat-i18n-fr.jar:${j2ee.server.home}/lib/tomcat-i18n-ja.jar:${j2ee.server.home}/lib/tomcat-i18n-ko.jar:${j2ee.server.home}/lib/tomcat-i18n-pt-BR.jar:${j2ee.server.home}/lib/tomcat-i18n-ru.jar:${j2ee.server.home}/lib/tomcat-i18n-zh-CN.jar:${j2ee.server.home}/lib/tomcat-jdbc.jar:${j2ee.server.home}/lib/tomcat-jni.jar:${j2ee.server.home}/lib/tomcat-util-scan.jar:${j2ee.server.home}/lib/tomcat-util.jar:${j2ee.server.home}/lib/tomcat-websocket.jar:${j2ee.server.home}/lib/websocket-api.jar:${j2ee.server.home}/lib/websocket-client-api.jar
|
||||
j2ee.server.type=Tomcat
|
||||
jar.compress=false
|
||||
javac.classpath=
|
||||
javac.classpath=\
|
||||
${file.reference.commons-lang3-3.17.0.jar}:\
|
||||
${file.reference.jakarta.servlet.jsp.jstl-2.0.0.jar}:\
|
||||
${file.reference.jakarta.servlet.jsp.jstl-api-2.0.0.jar}:\
|
||||
${file.reference.mysql-connector-java-8.0.23.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.debug=true
|
||||
|
@ -5,7 +5,24 @@
|
||||
<data xmlns="http://www.netbeans.org/ns/web-project/3">
|
||||
<name>ap33ApplicationSDIS-V2</name>
|
||||
<minimum-ant-version>1.6.5</minimum-ant-version>
|
||||
<web-module-libraries/>
|
||||
<web-module-libraries>
|
||||
<library dirs="200">
|
||||
<file>${file.reference.commons-lang3-3.17.0.jar}</file>
|
||||
<path-in-war>WEB-INF/lib</path-in-war>
|
||||
</library>
|
||||
<library dirs="200">
|
||||
<file>${file.reference.jakarta.servlet.jsp.jstl-2.0.0.jar}</file>
|
||||
<path-in-war>WEB-INF/lib</path-in-war>
|
||||
</library>
|
||||
<library dirs="200">
|
||||
<file>${file.reference.jakarta.servlet.jsp.jstl-api-2.0.0.jar}</file>
|
||||
<path-in-war>WEB-INF/lib</path-in-war>
|
||||
</library>
|
||||
<library dirs="200">
|
||||
<file>${file.reference.mysql-connector-java-8.0.23.jar}</file>
|
||||
<path-in-war>WEB-INF/lib</path-in-war>
|
||||
</library>
|
||||
</web-module-libraries>
|
||||
<web-module-additional-libraries/>
|
||||
<source-roots>
|
||||
<root id="src.dir" name="Source Packages"/>
|
||||
|
41
src/java/bdd/CaserneMySQL.java
Normal file
41
src/java/bdd/CaserneMySQL.java
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* bddd/CaserneMySQL.java
|
||||
*/
|
||||
package bdd;
|
||||
|
||||
import bean.Caserne;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Dominique_2
|
||||
*/
|
||||
public class CaserneMySQL {
|
||||
private final Connection laConnection = Connexion.getConnect("10.121.38.106",
|
||||
"sdis29",
|
||||
"adminBDsdis",
|
||||
"mdpBDsdis");
|
||||
public Caserne read(int id) {
|
||||
Caserne laCaserne = null;
|
||||
try {
|
||||
PreparedStatement prepStmt = null;
|
||||
String sql = "SELECT * FROM caserne WHERE id=?";
|
||||
prepStmt = laConnection.prepareStatement(sql);
|
||||
prepStmt.setInt(1, id);
|
||||
ResultSet result = prepStmt.executeQuery();
|
||||
if (result.next()) {
|
||||
laCaserne = new Caserne(result.getInt(1), result.getString(2),
|
||||
result.getString(3), result.getString(4));
|
||||
}
|
||||
prepStmt.close();
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("SQLExeption : " + ex.getMessage());
|
||||
System.out.println("SQLState : " + ex.getSQLState());
|
||||
System.out.println("Code erreur : " + ex.getErrorCode());
|
||||
}
|
||||
return laCaserne;
|
||||
}
|
||||
}
|
61
src/java/bdd/Connexion.java
Normal file
61
src/java/bdd/Connexion.java
Normal file
@ -0,0 +1,61 @@
|
||||
package bdd;
|
||||
/*
|
||||
Connexion.java
|
||||
Classe permettant d'établir une connexion avec une base de données mySQL
|
||||
*/
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
|
||||
public class 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)
|
||||
* @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
|
||||
* @return connection établie
|
||||
*/
|
||||
public static Connection getConnect(String serveur, String bdd, String nomUtil, String mdp) {
|
||||
//System.out.println("getConnect");
|
||||
if (connect == null) {
|
||||
new Connexion(serveur, bdd, nomUtil, mdp);
|
||||
}
|
||||
return connect;
|
||||
}
|
||||
}
|
80
src/java/bdd/ParamMySQL.java
Normal file
80
src/java/bdd/ParamMySQL.java
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* bdd/ParamMySQL.java
|
||||
*/
|
||||
package bdd;
|
||||
|
||||
|
||||
|
||||
import bean.Parametre;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Dominique_2
|
||||
*/
|
||||
public class ParamMySQL {
|
||||
|
||||
private final Connection laConnection = Connexion.getConnect("10.121.38.106",
|
||||
"sdis29",
|
||||
"adminBDsdis",
|
||||
"mdpBDsdis");
|
||||
/**
|
||||
* Recherche du paramètre correspondant au type et à l'indice passé en paramètres
|
||||
* @param typeParam
|
||||
* @param ind
|
||||
* @return Parametre concerné ou null si non trouvé
|
||||
*/
|
||||
public Parametre read(String typeParam, int ind) {
|
||||
Parametre leParam = null;
|
||||
try {
|
||||
PreparedStatement prepStmt = null;
|
||||
String sql = "SELECT * FROM parametre WHERE idType=? AND indice=?";
|
||||
prepStmt = laConnection.prepareStatement(sql);
|
||||
prepStmt.setString(1, typeParam);
|
||||
prepStmt.setInt(2, ind);
|
||||
ResultSet result = prepStmt.executeQuery();
|
||||
if (result.next()) {
|
||||
leParam = new Parametre(result.getString(1), result.getInt(2),
|
||||
result.getString(3));
|
||||
}
|
||||
prepStmt.close();
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("SQLExeption : " + ex.getMessage());
|
||||
System.out.println("SQLState : " + ex.getSQLState());
|
||||
System.out.println("Code erreur : " + ex.getErrorCode());
|
||||
}
|
||||
return leParam;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recherche de tous les paramètres du type passé en paramètre
|
||||
* @param unType
|
||||
* @return collection de Parametre correspondant au type
|
||||
*/
|
||||
public ArrayList<Parametre> readType(String unType) {
|
||||
ArrayList<Parametre> lesParam = new ArrayList();
|
||||
try {
|
||||
PreparedStatement prepStmt = null;
|
||||
String sql = "SELECT * FROM parametre WHERE idType=? ";
|
||||
prepStmt = laConnection.prepareStatement(sql);
|
||||
prepStmt.setString(1, unType);
|
||||
ResultSet result = prepStmt.executeQuery();
|
||||
Parametre leParam;
|
||||
while (result.next()) {
|
||||
leParam = new Parametre(result.getString(1), result.getInt(2),
|
||||
result.getString(3));
|
||||
lesParam.add(leParam);
|
||||
}
|
||||
prepStmt.close();
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("SQLExeption : " + ex.getMessage());
|
||||
System.out.println("SQLState : " + ex.getSQLState());
|
||||
System.out.println("Code erreur : " + ex.getErrorCode());
|
||||
}
|
||||
return lesParam;
|
||||
}
|
||||
}
|
338
src/java/bdd/PompierMySQL.java
Normal file
338
src/java/bdd/PompierMySQL.java
Normal file
@ -0,0 +1,338 @@
|
||||
/*
|
||||
* bdd/PompierMysql.java
|
||||
*/
|
||||
package bdd;
|
||||
|
||||
import bean.Caserne;
|
||||
import bean.Parametre;
|
||||
import bean.Pompier;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Dominique_2
|
||||
*/
|
||||
public class PompierMySQL {
|
||||
|
||||
private final Connection theConnection = Connexion.getConnect("10.121.38.106",
|
||||
"sdis29",
|
||||
"adminBDsdis",
|
||||
"mdpBDsdis");
|
||||
// Tableau des attributs mis à jour
|
||||
// 1ère dimension : noms des attributs en bdd
|
||||
// 2ème dimension : noms des champs transmis
|
||||
// 3ème dimension : type de données, i pour Integet, s pour String
|
||||
private String[][] lesAttributs = {
|
||||
{"id", "idCaserne", "nom", "prenom", "statut", "typePers", "mail", "login", "mdp", "adresse", "cp", "ville", "bip", "grade", "commentaire"},
|
||||
{"idP", "idC", "ztNom", "ztPrenom", "ldrStatut", "ldrType", "ztMail", "ztLogin", "ztMdp", "ztAdresse", "ztCP", "zlVille", "ztBip", "ldrGrade", "ztObs"},
|
||||
{"i", "i", "s", "s", "i", "i", "s", "s", "s", "s", "s", "s", "s", "i", "s"}
|
||||
};
|
||||
|
||||
/**
|
||||
* Recherche du pompier ayant le login et le mdp passé en paramètres
|
||||
*
|
||||
* @param login
|
||||
* @param mdp
|
||||
* @return Pompier correspondant ou null si non trouvé
|
||||
*/
|
||||
public Pompier readAuthentif(String login, String mdp) {
|
||||
Pompier lePompier = null;
|
||||
try {
|
||||
PreparedStatement prepStmt;
|
||||
String sql = "SELECT * FROM pompier WHERE login=? AND mdp=? ";
|
||||
|
||||
prepStmt = theConnection.prepareStatement(sql);
|
||||
prepStmt.setString(1, login);
|
||||
prepStmt.setString(2, mdp);
|
||||
ResultSet result = prepStmt.executeQuery();
|
||||
if (result.next()) {
|
||||
CaserneMySQL laCaserneMySQL = new CaserneMySQL();
|
||||
Caserne laCaserne = laCaserneMySQL.read(result.getInt(2));
|
||||
lePompier = constituerLePompier(result, laCaserne);
|
||||
}
|
||||
prepStmt.close();
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("SQLExeption : " + ex.getMessage());
|
||||
System.out.println("SQLState : " + ex.getSQLState());
|
||||
System.out.println("Code erreur : " + ex.getErrorCode());
|
||||
}
|
||||
return lePompier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recherche des pompiers volontaires de la caserne
|
||||
*
|
||||
* @param idCaserne
|
||||
* @return collection des pompiers concernés
|
||||
*/
|
||||
public ArrayList<Pompier> readLesPompiersCaserne(int idCaserne) {
|
||||
ArrayList<Pompier> lesPompiers = new ArrayList();
|
||||
try {
|
||||
PreparedStatement prepStmt;
|
||||
String sql = "SELECT * FROM pompier WHERE idCaserne=? AND Statut=1 AND typePers=2 ORDER BY nom, prenom";
|
||||
|
||||
prepStmt = theConnection.prepareStatement(sql);
|
||||
prepStmt.setInt(1, idCaserne);
|
||||
ResultSet result = prepStmt.executeQuery();
|
||||
CaserneMySQL laCaserneMySQL = new CaserneMySQL();
|
||||
Caserne laCaserne = laCaserneMySQL.read(idCaserne);
|
||||
while (result.next()) {
|
||||
Pompier unPompier = constituerLePompier(result, laCaserne);
|
||||
lesPompiers.add(unPompier);
|
||||
}
|
||||
prepStmt.close();
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("SQLExeption : " + ex.getMessage());
|
||||
System.out.println("SQLState : " + ex.getSQLState());
|
||||
System.out.println("Code erreur : " + ex.getErrorCode());
|
||||
}
|
||||
return lesPompiers;
|
||||
}
|
||||
|
||||
public Pompier constituerLePompier(ResultSet result, Caserne laCaserne) {
|
||||
Pompier lePompier = null;
|
||||
ParamMySQL leParamMySQL = new ParamMySQL();
|
||||
try {
|
||||
Parametre leStatut = leParamMySQL.read("statAgt", result.getInt(5));
|
||||
Parametre leType = leParamMySQL.read("typePer", result.getInt(6));
|
||||
Parametre leGrade = leParamMySQL.read("grade", result.getInt(15));
|
||||
lePompier = new Pompier(laCaserne, result.getInt(1),
|
||||
result.getString(3), result.getString(4),
|
||||
leStatut, leType,
|
||||
result.getString(7), result.getString(8),
|
||||
result.getString(9), result.getString(10),
|
||||
result.getString(11), result.getString(12),
|
||||
result.getString(13), leGrade, result.getString(16));
|
||||
//System.out.println("lePompier " + lePompier);
|
||||
} catch (SQLException ex) {
|
||||
Logger.getLogger(PompierMySQL.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return lePompier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recherche du dernier no de pompier utilisé pour une caserne
|
||||
*
|
||||
* @param idC : caserne concernée
|
||||
* @return dernier no de pompier utilisé dansla caserne
|
||||
*/
|
||||
public int getIdMax(int idC) {
|
||||
int max = 0;
|
||||
try {
|
||||
PreparedStatement prepStmt;
|
||||
String sql = "SELECT max(pId) FROM pompier WHERE pCis = ?";
|
||||
prepStmt = theConnection.prepareStatement(sql);
|
||||
prepStmt.setInt(1, idC);
|
||||
ResultSet result = prepStmt.executeQuery();
|
||||
if (result.first()) {
|
||||
max = result.getInt(1);
|
||||
}
|
||||
prepStmt.close();
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("SQLExeption : " + ex.getMessage());
|
||||
System.out.println("SQLState : " + ex.getSQLState());
|
||||
System.out.println("Code erreur : " + ex.getErrorCode());
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
public Pompier update(HashMap<String, Object> lesParametres, int idP) {
|
||||
// Date dateJ = new Date();
|
||||
// DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
// String dateDuJour = dateFormat.format(dateJ);
|
||||
Pompier lePompierMaj = null;
|
||||
// Constitution de la requête en fonction des données transmises
|
||||
String valeurs [] = new String[lesAttributs[1].length];
|
||||
String sql = "UPDATE pompier SET ";
|
||||
int nbAttributsMaj = 0;
|
||||
String virgule = "";
|
||||
for (HashMap.Entry unParam : lesParametres.entrySet()) {
|
||||
// Recherche attribut correspondant au champ trnasmis
|
||||
int i = 0;
|
||||
while (i < lesAttributs[1].length && !(lesAttributs[1][i].equals(unParam.getKey()))) {
|
||||
i++;
|
||||
}
|
||||
if (i < lesAttributs[0].length) {
|
||||
sql += virgule + lesAttributs[0][i] + "= ?";
|
||||
valeurs[nbAttributsMaj] = "("+lesAttributs[2][i]+")" + unParam.getValue();
|
||||
nbAttributsMaj++;
|
||||
virgule = ", ";
|
||||
}
|
||||
}
|
||||
sql += ", dateModif = ? WHERE id = ?;";
|
||||
// Alimentation des valeurs de la requête
|
||||
PreparedStatement prepStmt;
|
||||
try {
|
||||
prepStmt = theConnection.prepareStatement(sql);
|
||||
for (int i=0; i<nbAttributsMaj; i++) {
|
||||
if (valeurs[i].substring(0, 3).equals("(s)")) {
|
||||
prepStmt.setString(i+1, valeurs[i].substring(3));
|
||||
} else {
|
||||
prepStmt.setInt(i+1, Integer.parseInt(valeurs[i].substring(3)));
|
||||
}
|
||||
}
|
||||
prepStmt.setTimestamp(nbAttributsMaj+1, new Timestamp(Calendar.getInstance().getTimeInMillis()));
|
||||
prepStmt.setInt(nbAttributsMaj+2, idP);
|
||||
System.out.println("sql "+prepStmt);
|
||||
|
||||
int nbLigne = prepStmt.executeUpdate();
|
||||
|
||||
//Recherche du no du pompier créé
|
||||
if (nbLigne > 0) {
|
||||
System.out.println("nbLigne " + nbLigne);
|
||||
lePompierMaj = read(idP);
|
||||
System.out.println("lePompierMaj : "+ lePompierMaj);
|
||||
}
|
||||
prepStmt.close();
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("SQLExeption : " + ex.getMessage());
|
||||
System.out.println("SQLState : " + ex.getSQLState());
|
||||
System.out.println("Code erreur : " + ex.getErrorCode());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return lePompierMaj;
|
||||
// String sql = "UPDATE pompier "
|
||||
// + "SET pNom = ?, pPrenom = ?, pMail = ?, "
|
||||
// + "pLogin = ?, pMdp = ?, pAdresse = ?, pCp = ?, pVille = ?, "
|
||||
// + "pBip = ?, pGrade = ?, pCommentaire = ?, pDateModif = ? "
|
||||
// + "WHERE pCis=? AND pId=?; ";
|
||||
// return requeteMaj(sql, lesParametres);
|
||||
}
|
||||
|
||||
public Pompier create(HashMap<String, Object> lesParametres) {
|
||||
Pompier lePompierCree = null;
|
||||
// Constitution de la requête en fonction des données transmises
|
||||
String valeurs [] = new String[lesAttributs[1].length];
|
||||
String sql = "INSERT INTO pompier (";
|
||||
int nbAttributsMaj = 0;
|
||||
String virgule = "";
|
||||
for (HashMap.Entry unParam : lesParametres.entrySet()) {
|
||||
// Recherche attribut correspondant au champ trnasmis
|
||||
int i = 0;
|
||||
while (i < lesAttributs[1].length && !(lesAttributs[1][i].equals(unParam.getKey()))) {
|
||||
i++;
|
||||
}
|
||||
if (i < lesAttributs[0].length) {
|
||||
sql += virgule + lesAttributs[0][i];
|
||||
valeurs[nbAttributsMaj] = "("+lesAttributs[2][i]+")" + unParam.getValue();
|
||||
nbAttributsMaj++;
|
||||
virgule = ", ";
|
||||
}
|
||||
}
|
||||
sql += ", dateEnreg) values (?";
|
||||
for (int i=0; i<nbAttributsMaj; i++ ) {
|
||||
sql+= ", ?";
|
||||
}
|
||||
sql += ");";
|
||||
|
||||
// Alimentation des valeurs de la requête
|
||||
PreparedStatement prepStmt;
|
||||
try {
|
||||
prepStmt = theConnection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
|
||||
for (int i=0; i<nbAttributsMaj; i++) {
|
||||
if (valeurs[i].substring(0, 3).equals("(s)")) {
|
||||
prepStmt.setString(i+1, valeurs[i].substring(3));
|
||||
} else {
|
||||
prepStmt.setInt(i+1, Integer.parseInt(valeurs[i].substring(3)));
|
||||
}
|
||||
}
|
||||
prepStmt.setTimestamp(nbAttributsMaj+1, new Timestamp(Calendar.getInstance().getTimeInMillis()));
|
||||
System.out.println("sql "+prepStmt);
|
||||
|
||||
int nbLigne = prepStmt.executeUpdate();
|
||||
|
||||
//Recherche du no du pompier créé
|
||||
if (nbLigne > 0) {
|
||||
ResultSet result = prepStmt.getGeneratedKeys();
|
||||
if (result.first()) {
|
||||
int id = result.getInt(1);
|
||||
lePompierCree = read(id);
|
||||
System.out.println("lePompierCree : "+ lePompierCree);
|
||||
}
|
||||
}
|
||||
prepStmt.close();
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("SQLExeption : " + ex.getMessage());
|
||||
System.out.println("SQLState : " + ex.getSQLState());
|
||||
System.out.println("Code erreur : " + ex.getErrorCode());
|
||||
}
|
||||
|
||||
return lePompierCree;
|
||||
}
|
||||
|
||||
private Pompier requeteMaj(String sql, HashMap<String, Object> lesParametres) {
|
||||
int nbLigne = 0;
|
||||
try {
|
||||
PreparedStatement prepStmt;
|
||||
prepStmt = theConnection.prepareStatement(sql);
|
||||
prepStmt.setString(1, (String) lesParametres.get("ztNom"));
|
||||
prepStmt.setString(2, (String) lesParametres.get("ztPrenom"));
|
||||
prepStmt.setString(3, (String) lesParametres.get("ztMail"));
|
||||
prepStmt.setString(4, (String) lesParametres.get("ztLogin"));
|
||||
prepStmt.setString(5, (String) lesParametres.get("ztMdp"));
|
||||
prepStmt.setString(6, (String) lesParametres.get("ztAdresse"));
|
||||
prepStmt.setString(7, (String) lesParametres.get("ztCP"));
|
||||
prepStmt.setString(8, (String) lesParametres.get("ztVille"));
|
||||
prepStmt.setString(9, (String) lesParametres.get("ztBip"));
|
||||
prepStmt.setInt(10, (Integer) lesParametres.get("ldrGrade"));
|
||||
prepStmt.setString(11, (String) lesParametres.get("taObs"));
|
||||
//prepStmt.setDate(12, java.sql.Date.valueOf(java.time.LocalDate.now()));
|
||||
prepStmt.setTimestamp(12, new Timestamp(Calendar.getInstance().getTimeInMillis()));
|
||||
prepStmt.setInt(13, (Integer) lesParametres.get("idC"));
|
||||
prepStmt.setInt(14, (Integer) lesParametres.get("zhIdP"));
|
||||
if (sql.substring(0, 6).equals("INSERT")) {
|
||||
prepStmt.setInt(15, (Integer) lesParametres.get("idStatut"));
|
||||
prepStmt.setInt(16, (Integer) lesParametres.get("idType"));
|
||||
}
|
||||
|
||||
System.out.println(prepStmt);
|
||||
nbLigne = prepStmt.executeUpdate();
|
||||
prepStmt.close();
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("SQLExeption : " + ex.getMessage());
|
||||
System.out.println("SQLState : " + ex.getSQLState());
|
||||
System.out.println("Code erreur : " + ex.getErrorCode());
|
||||
}
|
||||
Pompier lePompierMaj = null;
|
||||
if (nbLigne > 0) {
|
||||
//lePompierMaj = read((Integer) lesParametres.get("idC"), (Integer) lesParametres.get("zhIdP"));
|
||||
}
|
||||
return lePompierMaj;
|
||||
}
|
||||
|
||||
public Pompier read(int idP) {
|
||||
Pompier unPompier = null;
|
||||
try {
|
||||
PreparedStatement prepStmt;
|
||||
String sql = "SELECT * FROM pompier WHERE id=? ";
|
||||
|
||||
prepStmt = theConnection.prepareStatement(sql);
|
||||
prepStmt.setInt(1, idP);
|
||||
ResultSet result = prepStmt.executeQuery();
|
||||
if (result.next()) {
|
||||
CaserneMySQL laCaserneMySQL = new CaserneMySQL();
|
||||
Caserne laCaserne = laCaserneMySQL.read(result.getInt(2));
|
||||
unPompier = constituerLePompier(result, laCaserne);
|
||||
}
|
||||
prepStmt.close();
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("SQLExeption : " + ex.getMessage());
|
||||
System.out.println("SQLState : " + ex.getSQLState());
|
||||
System.out.println("Code erreur : " + ex.getErrorCode());
|
||||
}
|
||||
return unPompier;
|
||||
}
|
||||
}
|
101
src/java/bean/Caserne.java
Normal file
101
src/java/bean/Caserne.java
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* bean/Caserne.java
|
||||
*/
|
||||
package bean;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Dominique_2
|
||||
*/
|
||||
public class Caserne {
|
||||
private int id;
|
||||
private String nom;
|
||||
private String adresse;
|
||||
private String tel;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getNom() {
|
||||
return nom;
|
||||
}
|
||||
|
||||
public void setNom(String nom) {
|
||||
this.nom = nom;
|
||||
}
|
||||
|
||||
public String getAdresse() {
|
||||
return adresse;
|
||||
}
|
||||
|
||||
public void setAdresse(String adresse) {
|
||||
this.adresse = adresse;
|
||||
}
|
||||
|
||||
public String getTel() {
|
||||
return tel;
|
||||
}
|
||||
|
||||
public void setTel(String tel) {
|
||||
this.tel = tel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Caserne(int cId, String cNom, String cAdresse, String cTel) {
|
||||
this.id = cId;
|
||||
this.nom = cNom;
|
||||
this.adresse = cAdresse;
|
||||
this.tel = cTel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 5;
|
||||
hash = 17 * hash + this.id;
|
||||
hash = 17 * hash + Objects.hashCode(this.nom);
|
||||
hash = 17 * hash + Objects.hashCode(this.adresse);
|
||||
hash = 17 * hash + Objects.hashCode(this.tel);
|
||||
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 Caserne other = (Caserne) obj;
|
||||
if (this.id != other.id) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(this.nom, other.nom)) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(this.adresse, other.adresse)) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(this.tel, other.tel)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Caserne{" + "id=" + id + ", nom=" + nom + ", adresse=" + adresse + ", tel=" + tel + '}';
|
||||
}
|
||||
|
||||
}
|
71
src/java/bean/Parametre.java
Normal file
71
src/java/bean/Parametre.java
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* bean/Parametre.java
|
||||
*/
|
||||
package bean;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Dominique_2
|
||||
*/
|
||||
public class Parametre {
|
||||
private String typParam;
|
||||
private int code;
|
||||
private String valeur;
|
||||
|
||||
|
||||
/**
|
||||
* @return the code
|
||||
*/
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param code the code to set
|
||||
*/
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the valeur
|
||||
*/
|
||||
public String getValeur() {
|
||||
return valeur;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param valeur the valeur to set
|
||||
*/
|
||||
public void setValeur(String valeur) {
|
||||
this.valeur = valeur;
|
||||
}
|
||||
|
||||
public Parametre(String typParam, int code, String valeur) {
|
||||
this.typParam = typParam;
|
||||
this.code = code;
|
||||
this.valeur = valeur;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the typParam
|
||||
*/
|
||||
public String getTypParam() {
|
||||
return typParam;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param typParam the typParam to set
|
||||
*/
|
||||
public void setTypParam(String typParam) {
|
||||
this.typParam = typParam;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Parametre{" + "typParam=" + typParam + ", code=" + code + ", valeur=" + valeur + '}';
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
223
src/java/bean/Pompier.java
Normal file
223
src/java/bean/Pompier.java
Normal file
@ -0,0 +1,223 @@
|
||||
/*
|
||||
* bean/Pompier.java
|
||||
*/
|
||||
package bean;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Dominique_2
|
||||
*/
|
||||
public class Pompier {
|
||||
private Caserne laCaserne;
|
||||
private int id;
|
||||
private String nom;
|
||||
private String prenom;
|
||||
private Parametre leStatut;
|
||||
private Parametre leType;
|
||||
private String mail;
|
||||
private String login;
|
||||
private String mdp;
|
||||
private String adresse;
|
||||
private String cp;
|
||||
private String ville;
|
||||
private String bip;
|
||||
private Parametre leGrade;
|
||||
private String commentaire;
|
||||
|
||||
public Caserne getLaCaserne() {
|
||||
return laCaserne;
|
||||
}
|
||||
|
||||
public void setLaCaserne(Caserne laCaserne) {
|
||||
this.laCaserne = laCaserne;
|
||||
}
|
||||
|
||||
public Pompier(Caserne laCaserne, int id, String nom, String prenom, Parametre leStatut, Parametre leType, String mail, String login, String mdp, String adresse, String cp, String ville, String bip, Parametre leGrade, String commentaire) {
|
||||
// this.laCaserne = laCaserne;
|
||||
// this.pId = pId;
|
||||
// this.pNom = pNom;
|
||||
// this.pPrenom = pPrenom;
|
||||
this(laCaserne, id, nom, prenom);
|
||||
this.leStatut = leStatut;
|
||||
this.leType = leType;
|
||||
this.mail = mail;
|
||||
this.login = login;
|
||||
this.mdp = mdp;
|
||||
this.adresse = adresse;
|
||||
this.cp = cp;
|
||||
this.ville = ville;
|
||||
this.bip = bip;
|
||||
this.leGrade = leGrade;
|
||||
this.commentaire = commentaire;
|
||||
}
|
||||
|
||||
public Pompier(Caserne laCaserne, int id, String nom, String prenom) {
|
||||
this.laCaserne = laCaserne;
|
||||
this.id = id;
|
||||
this.nom = nom;
|
||||
this.prenom = prenom;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
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 Parametre getLeStatut() {
|
||||
return leStatut;
|
||||
}
|
||||
|
||||
public void setLeStatut(Parametre leStatut) {
|
||||
this.leStatut = leStatut;
|
||||
}
|
||||
|
||||
public Parametre getLeType() {
|
||||
return leType;
|
||||
}
|
||||
|
||||
public void setLeType(Parametre leType) {
|
||||
this.leType = leType;
|
||||
}
|
||||
|
||||
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 String getAdresse() {
|
||||
return adresse;
|
||||
}
|
||||
|
||||
public void setAdresse(String adresse) {
|
||||
this.adresse = adresse;
|
||||
}
|
||||
|
||||
public String getCp() {
|
||||
return cp;
|
||||
}
|
||||
|
||||
public void setCp(String cp) {
|
||||
this.cp = cp;
|
||||
}
|
||||
|
||||
public String getVille() {
|
||||
return ville;
|
||||
}
|
||||
|
||||
public void setVille(String ville) {
|
||||
this.ville = ville;
|
||||
}
|
||||
|
||||
public String getBip() {
|
||||
return bip;
|
||||
}
|
||||
|
||||
public void setBip(String bip) {
|
||||
this.bip = bip;
|
||||
}
|
||||
|
||||
public Parametre getLeGrade() {
|
||||
return leGrade;
|
||||
}
|
||||
|
||||
public void setLeGrade(Parametre leGrade) {
|
||||
this.leGrade = leGrade;
|
||||
}
|
||||
|
||||
public String getCommentaire() {
|
||||
return commentaire;
|
||||
}
|
||||
|
||||
public void setCommentaire(String commentaire) {
|
||||
this.commentaire = commentaire;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 5;
|
||||
hash = 67 * hash + Objects.hashCode(this.laCaserne);
|
||||
hash = 67 * hash + this.id;
|
||||
hash = 67 * hash + Objects.hashCode(this.nom);
|
||||
hash = 67 * hash + Objects.hashCode(this.prenom);
|
||||
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 (!Objects.equals(this.laCaserne, other.laCaserne)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Pompier{" + "laCaserne=" + laCaserne + ", id=" + id + ", nom=" + nom + ", prenom=" + prenom + ", leStatut=" + leStatut + ", leType=" + leType + ", mail=" + mail + ", login=" + login + ", mdp=" + mdp + ", adresse=" + adresse + ", cp=" + cp + ", ville=" + ville + ", bip=" + bip + ", grade=" + leGrade + ", commentaire=" + commentaire + '}';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
15
src/java/doc/readMe
Normal file
15
src/java/doc/readMe
Normal file
@ -0,0 +1,15 @@
|
||||
Variables de session :
|
||||
Variables mises en session après authentification (AuthentifForm.java)
|
||||
lePompierConnecte : pompier authentifié
|
||||
lePompier : pompier à afficher dans pompierJSP
|
||||
lesGrades : collection des grades possibles (
|
||||
lesPeriodes : collections des périodes d'affectation possibles (nuit, matin, ...)
|
||||
lesStatuts : collection des statuts (pompier, chef de centre, resp. alertes)
|
||||
lesTypes : collection des types (pompier volontaires, perso médical, perso adm.)
|
||||
lesPompiers : collection des pompiers de la caserne, reseignée uniquement si le pompier connecté est un chef de centre
|
||||
Variables mises en session dans PompierServlet.java)
|
||||
lePompier : pompier à afficher dans pompierJSP
|
||||
|
||||
Attributs utilisés entre la servet PompierServlet.java et pompierJSP :
|
||||
page : 2 --> affichage des données du pompier connecté
|
||||
3 --> affichage des données d'un pompier de la caserne pour le chef de centre
|
229
src/java/filter/authentifFilter.java
Normal file
229
src/java/filter/authentifFilter.java
Normal file
@ -0,0 +1,229 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/Filter.java to edit this template
|
||||
*/
|
||||
package filter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import jakarta.servlet.Filter;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.FilterConfig;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author domin
|
||||
*/
|
||||
public class authentifFilter implements Filter {
|
||||
|
||||
private static final boolean debug = true;
|
||||
|
||||
// The filter configuration object we are associated with. If
|
||||
// this value is null, this filter instance is not currently
|
||||
// configured.
|
||||
private FilterConfig filterConfig = null;
|
||||
|
||||
public authentifFilter() {
|
||||
}
|
||||
|
||||
private void doBeforeProcessing(ServletRequest request, ServletResponse response)
|
||||
throws IOException, ServletException {
|
||||
if (debug) {
|
||||
log("authentifFilter:DoBeforeProcessing");
|
||||
}
|
||||
|
||||
// Write code here to process the request and/or response before
|
||||
// the rest of the filter chain is invoked.
|
||||
// For example, a logging filter might log items on the request object,
|
||||
// such as the parameters.
|
||||
/*
|
||||
for (Enumeration en = request.getParameterNames(); en.hasMoreElements(); ) {
|
||||
String name = (String)en.nextElement();
|
||||
String values[] = request.getParameterValues(name);
|
||||
int n = values.length;
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(name);
|
||||
buf.append("=");
|
||||
for(int i=0; i < n; i++) {
|
||||
buf.append(values[i]);
|
||||
if (i < n-1)
|
||||
buf.append(",");
|
||||
}
|
||||
log(buf.toString());
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private void doAfterProcessing(ServletRequest request, ServletResponse response)
|
||||
throws IOException, ServletException {
|
||||
if (debug) {
|
||||
log("authentifFilter:DoAfterProcessing");
|
||||
}
|
||||
|
||||
// Write code here to process the request and/or response after
|
||||
// the rest of the filter chain is invoked.
|
||||
// For example, a logging filter might log the attributes on the
|
||||
// request object after the request has been processed.
|
||||
/*
|
||||
for (Enumeration en = request.getAttributeNames(); en.hasMoreElements(); ) {
|
||||
String name = (String)en.nextElement();
|
||||
Object value = request.getAttribute(name);
|
||||
log("attribute: " + name + "=" + value.toString());
|
||||
|
||||
}
|
||||
*/
|
||||
// For example, a filter might append something to the response.
|
||||
/*
|
||||
PrintWriter respOut = new PrintWriter(response.getWriter());
|
||||
respOut.println("<P><B>This has been appended by an intrusive filter.</B>");
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param request The servlet request we are processing
|
||||
* @param response The servlet response we are creating
|
||||
* @param chain The filter chain we are processing
|
||||
*
|
||||
* @exception IOException if an input/output error occurs
|
||||
* @exception ServletException if a servlet error occurs
|
||||
*/
|
||||
public void doFilter(ServletRequest request, ServletResponse response,
|
||||
FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
|
||||
if (debug) {
|
||||
log("authentifFilter:doFilter()");
|
||||
}
|
||||
|
||||
// Cast de l'objet request
|
||||
HttpServletRequest requete = (HttpServletRequest) request;
|
||||
// Pas de filtrage des css, des images, des js
|
||||
String chemin = requete.getRequestURI().substring(requete.getContextPath().length());
|
||||
//System.out.println("Chemin : " + chemin);
|
||||
if (chemin.startsWith("/css") || chemin.startsWith("/images") || chemin.startsWith("/js")) {
|
||||
//System.out.println(" - passage ok");
|
||||
chain.doFilter(request, response);
|
||||
return;
|
||||
}
|
||||
// Récupération de la session
|
||||
HttpSession maSession = requete.getSession();
|
||||
// Récupération du booléen d'authentification
|
||||
boolean authentificationOK = false;
|
||||
if (maSession.getAttribute("lePompierConnecte") != null) {
|
||||
authentificationOK = true;
|
||||
}
|
||||
//System.out.println("authentificationOK : "+ authentificationOK);
|
||||
if (authentificationOK) {
|
||||
// Poursuite sans problème
|
||||
chain.doFilter(request, response);
|
||||
} else {
|
||||
// retour vers la page d'authentification
|
||||
request.getRequestDispatcher("authentification").forward(request, response);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the filter configuration object for this filter.
|
||||
*/
|
||||
public FilterConfig getFilterConfig() {
|
||||
return (this.filterConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the filter configuration object for this filter.
|
||||
*
|
||||
* @param filterConfig The filter configuration object
|
||||
*/
|
||||
public void setFilterConfig(FilterConfig filterConfig) {
|
||||
this.filterConfig = filterConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy method for this filter
|
||||
*/
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Init method for this filter
|
||||
*/
|
||||
public void init(FilterConfig filterConfig) {
|
||||
this.filterConfig = filterConfig;
|
||||
if (filterConfig != null) {
|
||||
if (debug) {
|
||||
log("authentifFilter:Initializing filter");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a String representation of this object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
if (filterConfig == null) {
|
||||
return ("authentifFilter()");
|
||||
}
|
||||
StringBuffer sb = new StringBuffer("authentifFilter(");
|
||||
sb.append(filterConfig);
|
||||
sb.append(")");
|
||||
return (sb.toString());
|
||||
}
|
||||
|
||||
private void sendProcessingError(Throwable t, ServletResponse response) {
|
||||
String stackTrace = getStackTrace(t);
|
||||
|
||||
if (stackTrace != null && !stackTrace.equals("")) {
|
||||
try {
|
||||
response.setContentType("text/html");
|
||||
PrintStream ps = new PrintStream(response.getOutputStream());
|
||||
PrintWriter pw = new PrintWriter(ps);
|
||||
pw.print("<html>\n<head>\n<title>Error</title>\n</head>\n<body>\n"); //NOI18N
|
||||
|
||||
// PENDING! Localize this for next official release
|
||||
pw.print("<h1>The resource did not process correctly</h1>\n<pre>\n");
|
||||
pw.print(stackTrace);
|
||||
pw.print("</pre></body>\n</html>"); //NOI18N
|
||||
pw.close();
|
||||
ps.close();
|
||||
response.getOutputStream().close();
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
PrintStream ps = new PrintStream(response.getOutputStream());
|
||||
t.printStackTrace(ps);
|
||||
ps.close();
|
||||
response.getOutputStream().close();
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getStackTrace(Throwable t) {
|
||||
String stackTrace = null;
|
||||
try {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
t.printStackTrace(pw);
|
||||
pw.close();
|
||||
sw.close();
|
||||
stackTrace = sw.getBuffer().toString();
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
return stackTrace;
|
||||
}
|
||||
|
||||
public void log(String msg) {
|
||||
filterConfig.getServletContext().log(msg);
|
||||
}
|
||||
|
||||
}
|
75
src/java/form/AuthentifForm.java
Normal file
75
src/java/form/AuthentifForm.java
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* form/authentifForm.java
|
||||
* Controle des données saisie dans le formulaire d'authentification
|
||||
*/
|
||||
package form;
|
||||
|
||||
import bdd.ParamMySQL;
|
||||
import bdd.PompierMySQL;
|
||||
import bean.Parametre;
|
||||
import bean.Pompier;
|
||||
import com.sun.net.httpserver.HttpServer;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import java.util.ArrayList;
|
||||
import util.CtrlSaisie;
|
||||
import util.MD5;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author domin
|
||||
*/
|
||||
public class AuthentifForm {
|
||||
String message;
|
||||
HttpServletRequest request;
|
||||
|
||||
public AuthentifForm(HttpServletRequest request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public boolean ctrlAuthentif() {
|
||||
request.removeAttribute("message");
|
||||
// Vérification de la présence des zones obligatoires
|
||||
String[] champsObligatoires = {"ztLogin", "ztMDP"};
|
||||
if (!CtrlSaisie.CtrlChampsObligatoires(request, champsObligatoires)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Vérification absence de chevron
|
||||
if (!CtrlSaisie.CtrlChevron(request)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean ctrlBDD() {
|
||||
boolean trouve = false;
|
||||
String login = request.getParameter("ztLogin");
|
||||
String mdp = MD5.encode(request.getParameter("ztMDP"));
|
||||
PompierMySQL pompierMySQL = new PompierMySQL();
|
||||
Pompier lePompier = pompierMySQL.readAuthentif(login, mdp);
|
||||
if (lePompier!= null) {
|
||||
trouve = true;
|
||||
HttpSession maSession = request.getSession();
|
||||
maSession.setAttribute("lePompierConnecte", lePompier);
|
||||
ParamMySQL paramMySQL = new ParamMySQL();
|
||||
ArrayList <Parametre> lesGrades = paramMySQL.readType("grade");
|
||||
maSession.setAttribute("lesGrades", lesGrades);
|
||||
ArrayList <Parametre> lesPeriodes = paramMySQL.readType("tranche");
|
||||
maSession.setAttribute("lesPeriodes", lesPeriodes);
|
||||
ArrayList <Parametre> lesStatuts = paramMySQL.readType("statAgt");
|
||||
maSession.setAttribute("lesStatuts", lesStatuts);
|
||||
ArrayList <Parametre> lesTypes = paramMySQL.readType("typePer");
|
||||
maSession.setAttribute("lesTypes", lesTypes);
|
||||
if (lePompier.getLeStatut().getCode()==2) {
|
||||
// Recherche des pompiers de la caserne
|
||||
ArrayList <Pompier> lesPompiers = pompierMySQL.readLesPompiersCaserne(lePompier.getLaCaserne().getId());
|
||||
maSession.setAttribute("lesPompiers", lesPompiers);
|
||||
}
|
||||
} else {
|
||||
request.setAttribute("message", "Login ou mot de passe erroné");
|
||||
}
|
||||
|
||||
return trouve;
|
||||
}
|
||||
}
|
118
src/java/servlets/AuthentifServlet.java
Normal file
118
src/java/servlets/AuthentifServlet.java
Normal file
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/Servlet.java to edit this template
|
||||
*/
|
||||
package servlets;
|
||||
|
||||
import bean.Pompier;
|
||||
import form.AuthentifForm;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.annotation.WebServlet;
|
||||
import jakarta.servlet.http.HttpServlet;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author sio
|
||||
*/
|
||||
@WebServlet(name = "AuthentifServlet", urlPatterns = {"/"})
|
||||
public class AuthentifServlet extends HttpServlet {
|
||||
|
||||
/**
|
||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||
* methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
try (PrintWriter out = response.getWriter()) {
|
||||
/* TODO output your page here. You may use following sample code. */
|
||||
out.println("<!DOCTYPE html>");
|
||||
out.println("<html>");
|
||||
out.println("<head>");
|
||||
out.println("<title>Servlet AuthentifServlet</title>");
|
||||
out.println("</head>");
|
||||
out.println("<body>");
|
||||
out.println("<h1>Servlet AuthentifServlet at " + request.getContextPath() + "</h1>");
|
||||
out.println("</body>");
|
||||
out.println("</html>");
|
||||
}
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* Handles the HTTP <code>GET</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
//processRequest(request, response);
|
||||
// Suppression des variables de session
|
||||
System.out.println("doGet AuthentifServlet");
|
||||
HttpSession maSession = request.getSession();
|
||||
maSession.removeAttribute("lePompierConnecte");
|
||||
maSession.removeAttribute("lesPompiers");
|
||||
maSession.removeAttribute("lePompier");
|
||||
getServletContext().getRequestDispatcher("/WEB-INF/authentifJSP.jsp").forward(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the HTTP <code>POST</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
//processRequest(request, response);
|
||||
Pompier lePompier = null;
|
||||
int page = 2;
|
||||
AuthentifForm af = new AuthentifForm(request);
|
||||
if (af.ctrlAuthentif() && af.ctrlBDD()) { // Contrôle des zones saisies et contrôle en base de données
|
||||
HttpSession maSession = request.getSession();
|
||||
lePompier = (Pompier) maSession.getAttribute("lePompierConnecte");
|
||||
if (lePompier.getLeStatut().getCode()==2) { // Chef de centre
|
||||
ArrayList <Pompier> lesPompiers = (ArrayList <Pompier>) maSession.getAttribute("lesPompiers");
|
||||
if (lesPompiers.size() > 0) {
|
||||
lePompier = lesPompiers.get(0);
|
||||
page = 3;
|
||||
}
|
||||
}
|
||||
request.setAttribute("page", page);
|
||||
//request.setAttribute("lePompier", lePompier);
|
||||
maSession.setAttribute("lePompier", lePompier);
|
||||
getServletContext().getRequestDispatcher("/WEB-INF/pompierJSP.jsp").forward(request, response);
|
||||
} else { // Une erreur a été détectée
|
||||
getServletContext().getRequestDispatcher("/WEB-INF/authentifJSP.jsp").forward(request, response);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
|
||||
}
|
64
src/java/util/CtrlSaisie.java
Normal file
64
src/java/util/CtrlSaisie.java
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* util/CtrlSaisie.java
|
||||
*/
|
||||
package util;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author domin
|
||||
*/
|
||||
public abstract class CtrlSaisie {
|
||||
/**
|
||||
* Vérifie la présence des champs obligatoires dans les paramètres transmis
|
||||
* @param request
|
||||
* @param champsObligatoires : tableau de chaine de caractères, avec le nom des champs obligatoires
|
||||
* @return booléen
|
||||
*/
|
||||
public static boolean CtrlChampsObligatoires(HttpServletRequest request, String[] champsObligatoires) {
|
||||
ArrayList <String> champsPresents = new ArrayList<>(request.getParameterMap().keySet());
|
||||
int i = 0;
|
||||
int nbChampsO = champsObligatoires.length;
|
||||
boolean erreur = false;
|
||||
while (erreur == false && i < nbChampsO && champsPresents.contains(champsObligatoires[i])){
|
||||
String value=request.getParameter(champsObligatoires[i]);
|
||||
if (value.trim().length() > 0) {
|
||||
i++;
|
||||
} else {
|
||||
erreur = true;
|
||||
}
|
||||
}
|
||||
if (i < nbChampsO) {
|
||||
request.setAttribute("message", "Veuillez renseigner toutes les zones obligatoires ("+i+')');
|
||||
}
|
||||
return (i>=nbChampsO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Contrôle si un champ de saisie contient un chevron
|
||||
* @param request
|
||||
* @return 0 sinon, -1 si oui
|
||||
*/
|
||||
public static boolean CtrlChevron(HttpServletRequest request) {
|
||||
// Contrôle car "<" dans les zones de texte
|
||||
Enumeration lesNoms = request.getParameterNames();
|
||||
int erreur = 0;
|
||||
//ArrayList <String> parameterNames = new ArrayList<String>(request.getParameterMap().keySet());
|
||||
while (erreur == 0 && lesNoms.hasMoreElements()) {
|
||||
Object paramObjet=lesNoms.nextElement();
|
||||
String param=(String) paramObjet;
|
||||
String value=request.getParameter(param);
|
||||
if (value.contains("<") || value.contains("<")) {
|
||||
String message = "Veuillez recommencer votre saisie, une anomalie sur une zone de saisie a été détectée ";
|
||||
request.setAttribute("message", message);
|
||||
erreur=1;
|
||||
}
|
||||
}
|
||||
return (erreur > 0) ? false : true;
|
||||
|
||||
}
|
||||
|
||||
}
|
36
src/java/util/MD5.java
Normal file
36
src/java/util/MD5.java
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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 util;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author sio
|
||||
*/
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public abstract class MD5 {
|
||||
|
||||
public static String encode(String uneChaine){
|
||||
MessageDigest md = null;
|
||||
try {
|
||||
md = MessageDigest.getInstance("MD5");
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
throw new IllegalArgumentException(ex);
|
||||
}
|
||||
md.update(uneChaine.getBytes());
|
||||
byte[] digest = md.digest();
|
||||
//myHash = DatatypeConverter.printHexBinary(digest).toLowerCase();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b : digest) {
|
||||
sb.append(String.format("%02x", b));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
41
web/WEB-INF/authentifJSP.jsp
Normal file
41
web/WEB-INF/authentifJSP.jsp
Normal file
@ -0,0 +1,41 @@
|
||||
<%--
|
||||
Document : authentifJSP
|
||||
Created on : 23 oct. 2021, 10:02:18
|
||||
Author : domin
|
||||
--%>
|
||||
<%@include file= "jspf/debutJSP.jspf" %>
|
||||
<body>
|
||||
<c:set var="page" value="1" scope="request" />
|
||||
<%@include file= "jspf/header.jspf" %>
|
||||
<div class="container">
|
||||
|
||||
<section id="contenuAffiche">
|
||||
<fieldset id="authentif">
|
||||
<legend>
|
||||
Authentification
|
||||
</legend>
|
||||
<form id="fAuthentif" method="POST" action="authentification">
|
||||
<div class="mb-3 mt-3">
|
||||
<label for="ztLogin"> Login * </label>
|
||||
<input type="text" placeholder="login" id="ztLogin"
|
||||
autocomplete="username" name="ztLogin" class="form-control" required />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="ztMDP"> Mot de passe * </label>
|
||||
<input type="password" placeholder="mdp" id="ztMDP"
|
||||
name="ztMDP" class="form-control" required />
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<button type="submit" value="Valider" class="btn btn-danger"><i class="bi bi-check2"></i> Valider</button>
|
||||
</div>
|
||||
</form>
|
||||
${message}
|
||||
</fieldset>
|
||||
</section> <!-- /section id contenuAffiche -->
|
||||
<%@include file= "jspf/footer.jspf" %>
|
||||
</div> <!-- /div class container -->
|
||||
|
||||
<!-- Bootstrap Bundle with Popper -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
|
||||
</body>
|
||||
</html>
|
16
web/WEB-INF/jspf/debutJSP.jspf
Normal file
16
web/WEB-INF/jspf/debutJSP.jspf
Normal file
@ -0,0 +1,16 @@
|
||||
<%-- jspf/debutJSP.jsp --%>
|
||||
<%@page contentType="text/html" pageEncoding="UTF-8"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<!-- Bootstrap CSS -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.6.1/font/bootstrap-icons.css">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
|
||||
<link href="css/mycss.css" rel="stylesheet" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico" />
|
||||
<title>SDIS29</title>
|
||||
</head>
|
5
web/WEB-INF/jspf/footer.jspf
Normal file
5
web/WEB-INF/jspf/footer.jspf
Normal file
@ -0,0 +1,5 @@
|
||||
<%-- jspf/footer.jspf --%>
|
||||
<%@ page pageEncoding="UTF-8" %>
|
||||
<footer>
|
||||
<p>SDIS 29 - 58, avenue de Keradennec - 29337 QUIMPER CEDEX - 02 98 10 31 50</p>
|
||||
</footer>
|
21
web/WEB-INF/jspf/formChoixPompier.jspf
Normal file
21
web/WEB-INF/jspf/formChoixPompier.jspf
Normal file
@ -0,0 +1,21 @@
|
||||
<%-- any content can be specified here e.g.: --%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ page pageEncoding="UTF-8" %>
|
||||
|
||||
<form action="pompier" method="POST" id="fChoixPompier" name="fChoixPompier">
|
||||
<div class="row">
|
||||
<div class="col-md-9">
|
||||
<label for="ldrPompier">Choix du pompier : </label>
|
||||
ici se trouvera la liste déroulante des pompiers
|
||||
</div>
|
||||
<div class="col-md-3" id="btAfficherPompier" name="btAfficherPompier">
|
||||
<!--<input class="btn btn-danger" name="btAfficherPompier" type="submit" value="Afficher" /> -->
|
||||
<button class="btn btn-danger" name="btAfficherPompier" value="Afficher" type="submit"><i class="bi bi-eye-fill"></i> Afficher</button>
|
||||
<button class="btn btn-danger ms-5" name="btAfficherPompier" value="Ajouter" type="submit"> <i class="bi bi-plus-lg"></i> Ajouter</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
4
web/WEB-INF/jspf/formulairePompier.jspf
Normal file
4
web/WEB-INF/jspf/formulairePompier.jspf
Normal file
@ -0,0 +1,4 @@
|
||||
<%@ page pageEncoding="UTF-8" %>
|
||||
Ici se trouvera le formulaire permettant de gérer les informations sur un pompier pour les afficher, les modifier ou les créer
|
||||
|
||||
|
45
web/WEB-INF/jspf/header.jspf
Normal file
45
web/WEB-INF/jspf/header.jspf
Normal file
@ -0,0 +1,45 @@
|
||||
<%-- jspf/header.jspf --%>
|
||||
<%@ page pageEncoding="UTF-8" %>
|
||||
<c:set var="blancs8" value=" " scope="page" />
|
||||
<header>
|
||||
<div class="container" id="entete">
|
||||
|
||||
<img id="logo" src="images/logo-sdis.png" alt='logo sdis29' />
|
||||
<div id="identite">
|
||||
<div id="login">
|
||||
<c:choose>
|
||||
<c:when test="${empty sessionScope.lePompierConnecte}">
|
||||
<h4>Bienvenue</h4>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<h4>Bienvenue XXXXX
|
||||
</h4>
|
||||
|
||||
<button type="button" class="btn btn-warning fs-4" title="Déconnexion">
|
||||
<a href="authentification">
|
||||
<i class="bi bi-box-arrow-right heading" width="32" height="32" fill="currentColor"></i> Déconnexion
|
||||
</a>
|
||||
</button>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</div>
|
||||
<h4>Service Départemental d'Incendie et de Secours du Finistère</h4>
|
||||
|
||||
Afficher ici les coordonnées de la caserne du pompier connecté
|
||||
|
||||
<nav class="navbar navbar-expand-sm bg-danger navbar-dark">
|
||||
<div class="container-fluid">
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<span class="nav-link"><pre>${blancs8}</pre> </span>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
Barre de navigation ici
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</nav>
|
||||
</div> <!-- fin id=identie -->
|
||||
</div> <!-- fin class=container -->
|
||||
</header>
|
50
web/WEB-INF/pompierJSP.jsp
Normal file
50
web/WEB-INF/pompierJSP.jsp
Normal file
@ -0,0 +1,50 @@
|
||||
<%--
|
||||
pompierJSP.jsp
|
||||
--%>
|
||||
<%@page contentType="text/html" pageEncoding="UTF-8"%>
|
||||
<%@include file= "jspf/debutJSP.jspf" %>
|
||||
<body>
|
||||
|
||||
<%@include file= "jspf/header.jspf" %>
|
||||
<div class="container">
|
||||
<section id="contenuAffiche" class="row">
|
||||
<c:set var="legend" value="Mes données" scope="page" />
|
||||
<c:if test="${sessionScope.lePompierConnecte.getLeStatut().getCode() eq 2}" var="testChef" scope="page">
|
||||
<c:if test="${sessionScope.lePompierConnecte.getId() ne lePompier.getId()}" var="testAffich" scope="page">
|
||||
<c:set var="legend" scope="page">
|
||||
Données du pompier
|
||||
</c:set>
|
||||
<c:if test="${sessionScope.lePompier==null}" var="testCreation" scope="page">
|
||||
<c:set var="legend" scope="page">
|
||||
Données du pompier à créer
|
||||
</c:set>
|
||||
</c:if>
|
||||
<fieldset class="row mb-10 text-center">
|
||||
<%@include file= "jspf/formChoixPompier.jspf" %>
|
||||
</fieldset>
|
||||
</c:if>
|
||||
</c:if>
|
||||
|
||||
<fieldset class="row mt-1 mb-10">
|
||||
<legend>
|
||||
${legend}
|
||||
</legend>
|
||||
|
||||
<%@include file= "jspf/formulairePompier.jspf" %>
|
||||
</fieldset>
|
||||
</section>
|
||||
|
||||
<%@include file= "jspf/footer.jspf" %>
|
||||
</div> <!-- /div class container -->
|
||||
|
||||
<!-- Bootstrap Bundle with Popper -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- Code postaux -->
|
||||
<script src="js/ctrlCodePostal.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
|
86
web/css/mycss.css
Normal file
86
web/css/mycss.css
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
css/mycss.css
|
||||
*/
|
||||
|
||||
body {
|
||||
background-color: #ECECEC;
|
||||
}
|
||||
#contenuAffiche {
|
||||
display: flex;
|
||||
justify-content:center;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
background-color: #ffffff;
|
||||
border-radius: 5px;
|
||||
}
|
||||
#authentif {
|
||||
width : 50%;
|
||||
}
|
||||
fieldset {
|
||||
border-radius: 5px;
|
||||
padding: 5px;
|
||||
border: 1px solid #DB0005;
|
||||
width: 100%;
|
||||
}
|
||||
legend {
|
||||
margin-bottom:0px;
|
||||
padding-bottom: 0px;
|
||||
}
|
||||
footer {
|
||||
margin-top: 10px;
|
||||
background-color: #EDEDED;
|
||||
text-align: center;
|
||||
font-size: smaller;
|
||||
padding: 10px;
|
||||
/*border-bottom: 3px solid #DB0005; */
|
||||
}
|
||||
header {
|
||||
background-color: #333333;
|
||||
color: #EDEDED;
|
||||
padding: 10px;
|
||||
|
||||
}
|
||||
#entete {
|
||||
display: flex;
|
||||
/* align-items: center; */
|
||||
align-items: flex-end ;
|
||||
}
|
||||
|
||||
li {
|
||||
text-align: center;
|
||||
}
|
||||
li:not(:first-child) {
|
||||
border-left: 2px solid #EDEDED;
|
||||
}
|
||||
#identite {
|
||||
width : 100%;
|
||||
}
|
||||
.navbar {
|
||||
padding: 0 0 0 0;
|
||||
border-radius: 5px;
|
||||
margin-left: -8%;
|
||||
}
|
||||
#logo {
|
||||
z-index:1; /* arriere plan */
|
||||
}
|
||||
#login {
|
||||
background-color: #EDEDED;
|
||||
color: #333333;
|
||||
display: flex;
|
||||
justify-content:space-around;
|
||||
align-items: center;
|
||||
margin-left: -8%;
|
||||
}
|
||||
|
||||
button a {
|
||||
text-decoration:none;
|
||||
color: #333333;
|
||||
}
|
||||
aside, #btAfficherPompier {
|
||||
justify-content: center;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
select[readonly] {
|
||||
pointer-events: none;
|
||||
}
|
BIN
web/images/favicon.ico
Normal file
BIN
web/images/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
BIN
web/images/logo-sdis.png
Normal file
BIN
web/images/logo-sdis.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
BIN
web/images/pompier.png
Normal file
BIN
web/images/pompier.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
28
web/js/ctrlCodePostal.js
Normal file
28
web/js/ctrlCodePostal.js
Normal file
@ -0,0 +1,28 @@
|
||||
// Recherche de la ou des villes correspondantes au code postal saisi (exemple 54490 --> 7 villes)
|
||||
ztCP.onchange = function () {
|
||||
//alert("ztCP a changé");
|
||||
msgCP.textContent = "";
|
||||
zlVille.length = 0;
|
||||
const XHTTP = new XMLHttpRequest();
|
||||
XHTTP.onload = function () {
|
||||
if (this.status != 200) {
|
||||
msgCP.textContent = "Code postal erroné";
|
||||
} else {
|
||||
var lesVilles = JSON.parse(this.responseText);
|
||||
var info = "";
|
||||
if (lesVilles.length > 1) {
|
||||
info += "<optgroup label='Les villes du code postal' />";
|
||||
}
|
||||
for (var i = 0; i < lesVilles.length; i++) {
|
||||
var uneVille = lesVilles[i];
|
||||
info += "<option value='" + uneVille.libelleAcheminement + "'>";
|
||||
info += uneVille.libelleAcheminement + '</option>';
|
||||
}
|
||||
zlVille.innerHTML = info;
|
||||
}
|
||||
}
|
||||
var cp = ztCP.value;
|
||||
XHTTP.open("GET", "https://apicarto.ign.fr/api/codes-postaux/communes/" + cp);
|
||||
XHTTP.send();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user