Incluidas clases para permitir el login de diferentes tipos de usuaario.

* POJO para usuario logeado.
* Hash para claves de usuarios
* Métodos EJB para login
This commit is contained in:
mgarcianun
2019-12-06 00:18:20 +01:00
parent 96c514f8a5
commit 32ce0a7eb6
8 changed files with 218 additions and 14 deletions

View File

@@ -9,6 +9,7 @@ import TO.MedicalSpecialtyTO;
import TO.PatientTO;
import TO.PrimaryHealthCareCenterTO;
import TO.SpecialistDoctorTO;
import common.HashUtils;
import jpa.FamilyDoctorJPA;
import jpa.MedicalSpecialtyJPA;
import jpa.PatientJPA;
@@ -45,7 +46,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
public PatientTO registerPatient(Integer id, String nif, String name, String surname, String password, String email) {
PatientTO paTO = null;
PatientJPA ms = new PatientJPA(id, nif, name, surname, password, email);
PatientJPA ms = new PatientJPA(id, nif, name, surname, HashUtils.hashMD5(password), email);
entman.persist(ms);
paTO = new PatientTO(ms.getId(), ms.getNif(), ms.getName(), ms.getSurname(), ms.getPassword(), ms.getEmail());
@@ -59,7 +60,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
// TODO: Lanzar error si no se encuentra la especialidad.
if (ms != null) {
SpecialistDoctorJPA sd = new SpecialistDoctorJPA(id, nif, name, surname, password, email);
SpecialistDoctorJPA sd = new SpecialistDoctorJPA(id, nif, name, surname, HashUtils.hashMD5(password), email);
entman.persist(sd);
sdTO = new SpecialistDoctorTO(sd.getId(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail());
}
@@ -75,7 +76,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
// TODO: Lanzar error si no encontramos el cap!!!!!
if (phcC != null) {
FamilyDoctorJPA fd = new FamilyDoctorJPA(id, nif, name, surname, password, email);
FamilyDoctorJPA fd = new FamilyDoctorJPA(id, nif, name, surname, HashUtils.hashMD5(password), email);
fd.setPrimaryHealthCareCenter(phcC);
entman.persist(fd);
@@ -94,7 +95,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
fd.setNif(nif);
fd.setName(name);
fd.setSurname(surname);
fd.setPassword(password);
fd.setPassword(HashUtils.hashMD5(password));
fd.setEmail(email);
entman.persist(fd);
@@ -117,7 +118,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
sd.setNif(nif);
sd.setName(name);
sd.setSurname(surname);
sd.setPassword(password);
sd.setPassword(HashUtils.hashMD5(password));
sd.setEmail(email);
sd.setMedicalSpecialty(ms);
@@ -137,7 +138,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
fd.setNif(nif);
fd.setName(name);
fd.setSurname(surname);
fd.setPassword(password);
fd.setPassword(HashUtils.hashMD5(password));
fd.setEmail(email);
// TODO: Es posible actualizar el cap? ¿No debería utilizar el método