public UtilisateurWeb PatientSupprMedicament(string ValueJSON, string Token) { UtilisateurWeb UtilWeb = ServiceSecurite.UtilisateurWebDepuisValeur(ValueJSON); //convertion ServiceSecurite.IsTokenValid(Token); //teste du token long return(Conversion((new ServicePatient()).SupprMedicamentAPatient(UtilWeb.MesPatients[0].IDWeb, UtilWeb.MesPatients[0].MesMedicaments[0].ID))); }
/// <summary> /// récupère le token et le vérifie avec le basic Token /// </summary> /// <param name="Token"></param> /// <returns></returns> public static void TokenBasicValide(UtilisateurWeb Utilisateur) { if (Encoding.UTF8.GetString(Convert.FromBase64String(Utilisateur.Token)) != _CleeBasic) { throw new TokenInvalidException(Utilisateur, "Le tocken est invalide"); } }
public UtilisateurWeb PatientAjoutMigraine(string ValueJSON, string Token) { UtilisateurWeb UtilWeb = ServiceSecurite.UtilisateurWebDepuisValeur(ValueJSON); //convertion ServiceSecurite.IsTokenValid(Token); //teste du token long return(Conversion((new ServicePatient()).AjoutMigraine(UtilWeb.IDWeb, UtilWeb.MesMigraines[0], true))); }
public UtilisateurWeb PatientSupprMigraineTel(string ValueJSON) { UtilisateurWeb UtilWeb = ServiceSecurite.UtilisateurWebDepuisValeur(ValueJSON); //convertion ServiceSecurite.IsTokenTelephoneValid(UtilWeb.Identifiant, UtilWeb.Token); //teste du token long return(Conversion((new ServicePatient()).SupprimerMigraineAPatient(UtilWeb.IDWeb, UtilWeb.MesMigraines[0]))); }
public UtilisateurWeb ModificationCompte(string ValueJSON, String Token) { UtilisateurWeb UtilWeb = ServiceSecurite.UtilisateurWebDepuisValeur(ValueJSON); //convertion ServiceSecurite.IsTokenValid(Token); //teste du token long Compte retour = ServiceSecurite.UtilisateurWebVersCompte(UtilWeb); if (retour is Medecin) { return(Conversion((new ServiceMedecin()).Modification(retour as Medecin))); } else if (retour is Patient) { return(Conversion((new ServicePatient()).Modification(retour as Patient))); } else { return(null); } //MedecinDAO medecinDAO = new MedecinDAO(); //int retourIDCompte = medecinDAO.ModificationMedecin(IdMedecin, Adress, Telephone, InfoComplementaire); //on va chercher le patient tout en le modifiant //if (retourIDCompte != -1) //{ // //retourIDCompte = new CompteDAO().ChangementInformation(retourIDCompte, Login, null, Nom, Prenom); //on transmet l'information de d'Id du compte et on transmet a CompteDAO l'ordre de changer le mot de passe. puis on récupère l'information que l'opération c'est bien passé // //if (retourIDCompte != -1) return medecinDAO.VoirMedecinSimple(IdMedecin); //} //return null; }
public UtilisateurWeb GetMedecinTel(string ValueJSON) { UtilisateurWeb UtilWeb = ServiceSecurite.UtilisateurWebDepuisValeur(ValueJSON); //convertion ServiceSecurite.IsTokenTelephoneValid(UtilWeb.Identifiant, UtilWeb.Token); //teste du téléphone return(Conversion(new ServiceMedecin().GetMedecin(UtilWeb.MesMedecin[0].IDWeb))); }
public List <Modele.Medicament> GetListTotalMedicaments(string Value, string Token) { UtilisateurWeb UtilWeb = ServiceSecurite.UtilisateurWebDepuisValeur(Value); //convertion ServiceSecurite.IsTokenValid(Token); //teste du token long return(new ServiceMedicament().ListeTotalMedicaments()); }
public UtilisateurWeb PatientAjoutFacteur(string ValueJSON, string Token) { ServiceSecurite.IsTokenValid(Token); //teste du token long UtilisateurWeb UtilWeb = ServiceSecurite.UtilisateurWebDepuisValeur(ValueJSON); //convertion return(Conversion((new ServicePatient()).AjouterFacteur(UtilWeb.IDWeb, UtilWeb.MesFacteurs[0].ID))); }
public List <Medicament> GetListMedicamentsDuPatient(string Value, string Token) { UtilisateurWeb UtilWeb = ServiceSecurite.UtilisateurWebDepuisValeur(Value); //convertion ServiceSecurite.IsTokenValid(Token); //teste du token long return(new ServicePatient().ListeMedicaments(UtilWeb.IDWeb)); }
public List <UtilisateurWeb> GetListPatient(string ValueJSON, string Token) { UtilisateurWeb UtilWeb = ServiceSecurite.UtilisateurWebDepuisValeur(ValueJSON); //convertion ServiceSecurite.IsTokenValid(Token); //teste du token long return(RetourListPatient(new ServicePatient().GetListPatient(UtilWeb.Nom))); }
public UtilisateurWeb GetPatient(string ValueJSON, string Token) { UtilisateurWeb UtilWeb = ServiceSecurite.UtilisateurWebDepuisValeur(ValueJSON); //convertion ServiceSecurite.IsTokenValid(Token); //teste du token long return(Conversion(new ServicePatient().GetPatient(UtilWeb.IDWeb))); }
public List <Facteur> PatientListeFacteurs(string ValueJSON, string Token) { UtilisateurWeb UtilWeb = ServiceSecurite.UtilisateurWebDepuisValeur(ValueJSON); //convertion ServiceSecurite.IsTokenValid(Token); //teste du token long return((new ServicePatient()).ListFacteurs(UtilWeb.IDWeb)); }
//private string HashPassword(string pass) //{ // byte[] bytes = Encoding.Unicode.GetBytes(pass + "AjouteFinale"); // SHA256Managed hashstring = new SHA256Managed(); // byte[] hash = hashstring.ComputeHash(bytes); // string hashString = string.Empty; // foreach (byte x in hash) // { // hashString += String.Format("{0:x2}", x); // } // return hashString; //} /// <summary> /// transforme des donné Json en classe UtilisateurWeb /// </summary> /// <param name="Token"></param> /// <returns></returns> public static UtilisateurWeb UtilisateurWebDepuisValeur(string Token) { string key = Encoding.UTF7.GetString(Convert.FromBase64String(Token)); using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(key))) { DataContractJsonSerializer deserializer = new DataContractJsonSerializer(typeof(UtilisateurWeb)); UtilisateurWeb compteWeb = (UtilisateurWeb)deserializer.ReadObject(ms); return(compteWeb); } }
public static UtilisateurWeb VerificationToken(string value) { string key = Encoding.UTF8.GetString(Convert.FromBase64String(value)); using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(key))) { DataContractJsonSerializer deserializer = new DataContractJsonSerializer(typeof(UtilisateurWeb)); UtilisateurWeb utilisateur = (UtilisateurWeb)deserializer.ReadObject(ms); IsTokenTelephoneValid(utilisateur.Identifiant, utilisateur.Token); return(utilisateur); } }
//public List<Modele.Medicament> GetListMedicaments(string Value) public List <Medicament> GetListMedicaments(string Value, string Token) { UtilisateurWeb UtilWeb = ServiceSecurite.UtilisateurWebDepuisValeur(Value); //convertion ServiceSecurite.IsTokenValid(Token); //teste du token long //UtilisateurWeb test = new UtilisateurWeb(); //List<Medicament> toto = new List<Medicament>(); //Medicament tata = new Medicament() { ID = 0, DenominationMedicament = "Medoc" }; //toto.Add(tata); //test.IDWeb = 10; return(new ServiceMedicament().ListeMedicaments(UtilWeb.MesMedicaments[0].DenominationMedicament)); //Docteur //return new ServiceMedicament().ListeMedicaments(UtilWeb.MesMedicaments[0].DenominationMedicament); }
public UtilisateurWeb AttributionPatient(string ValueJSON, string Token) { UtilisateurWeb UtilWeb = ServiceSecurite.UtilisateurWebDepuisValeur(ValueJSON); //convertion ServiceSecurite.IsTokenValid(Token); //teste du token long Compte retour = ServiceSecurite.UtilisateurWebVersCompte(UtilWeb); if (retour is Medecin) { return(Conversion((new ServiceMedecin()).AttributionPatient(UtilWeb.MesPatients[0].IDWeb, UtilWeb.IDWeb))); } else { return(null); } }
/// <summary> /// transcription du Token en objet Compte avec cryptage du mot de passe /// </summary> /// <param name="Token"></param> /// <returns></returns> public static Compte GetCompteSecurite(string Token) { string key = Encoding.UTF8.GetString(Convert.FromBase64String(Token)); using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(key))) { DataContractJsonSerializer deserializer = new DataContractJsonSerializer(typeof(Compte)); Compte compte = (Compte)deserializer.ReadObject(ms); UtilisateurWeb utilisateur = new UtilisateurWeb() { Identifiant = compte.Identifiant, Token = compte.Token }; if (key == null) { throw new AutentificationIncorrecteException("Les information de login / mot de passe sont incorrecte"); } if (String.IsNullOrEmpty(compte.Identifiant)) { throw new AutentificationIncorrecteException("Le login est nul ou vide"); } if (String.IsNullOrEmpty(compte.MotDePass)) { throw new AutentificationIncorrecteException("Le mot de passe est nul ou vide"); } if (String.IsNullOrEmpty(compte.Token)) { throw new TokenInvalidException(utilisateur, "Le token est nul ou vide"); } if (compte.Token != _CleeBasic) { throw new TokenInvalidException(utilisateur, "Le token est invalide"); } compte.MotDePass = HashMotDePass(compte.MotDePass); string retourMotDePass = new CompteDAO().GetMotDePass(compte.Identifiant); if (retourMotDePass == "" | compte.MotDePass != retourMotDePass) { throw new AutentificationIncorrecteException(compte.Identifiant, "Identifiant ou mot de passe incorrecte"); } return(compte); } }
public UtilisateurWeb TelephoneLogin(string Token) { UtilisateurWeb utilisateurWeb = ServiceSecurite.GetTelephoneSecurite(Token); //teste du compte et du token basic. Si incorrecte passage en catch PatientDAO _PatientDAO = new PatientDAO(); MedecinDAO _MedecinDAO = new MedecinDAO(); if (_PatientDAO.IsPatient(utilisateurWeb.Identifiant)) { return(Conversion(_PatientDAO.LoginTelephone(utilisateurWeb.Identifiant, utilisateurWeb.MotDePass, utilisateurWeb.TelephonePortable))); } else if (_MedecinDAO.IsMedecin(utilisateurWeb.Identifiant)) { throw new TypeCompteException(utilisateurWeb, "Ce compte n'est pas celui d'un patient"); } else { return(null); } }
public UtilisateurWeb ChangeMotDePass(string ValueJSON, string Token) { UtilisateurWeb UtilWeb = ServiceSecurite.UtilisateurWebDepuisValeur(ValueJSON); //convertion ServiceSecurite.IsTokenValid(Token); //teste du token long Compte retour = ServiceSecurite.UtilisateurWebVersCompte(UtilWeb); if (retour is Medecin) { return(Conversion((new ServiceMedecin()).NouveauMotDePass(retour as Medecin))); } else if (retour is Patient) { return(Conversion((new ServicePatient()).NouveauMotDePass(retour as Patient))); } else { return(null); } }
public UtilisateurWeb CreationCompte(string ValueJSON) { UtilisateurWeb UtilWeb = ServiceSecurite.UtilisateurWebDepuisValeur(ValueJSON); //convertion ServiceSecurite.TokenBasicValide(UtilWeb); //teste du token. Si incorect passage en catch Compte retour = ServiceSecurite.UtilisateurWebVersCompte(UtilWeb); if (retour is Medecin) { return(Conversion((new ServiceMedecin()).AjoutMedecin(retour as Medecin))); } else if (retour is Patient) { return(Conversion((new ServicePatient()).AjoutPatient(retour as Patient))); } else { return(null); } }
public UtilisateurWeb TelephoneLoginToken(string Token) { UtilisateurWeb utilisateurWeb = ServiceSecurite.VerificationToken(Token); PatientDAO _PatientDAO = new PatientDAO(); MedecinDAO _MedecinDAO = new MedecinDAO(); if (_PatientDAO.IsPatient(utilisateurWeb.Identifiant)) { return(Conversion(_PatientDAO.LoginTelephoneToken(utilisateurWeb.Identifiant))); } else if (_MedecinDAO.IsMedecin(utilisateurWeb.Identifiant)) { throw new TypeCompteException(utilisateurWeb, "Ce compte n'est pas celui d'un patient"); } else { return(null); } }
public UtilisateurWebInexistantException(string message, UtilisateurWeb UtilisateurWeb) : base(message) { this.UtilisateurWeb = UtilisateurWeb; this.UtilisateurWeb.Erreur = message; }
//public static TokenValide(string tokenlongue) //{ // IsTokenValid(tokenlongue); //} /// <summary> /// Transforme l'UtilisateurWeb en un Patient ou un Medecin. Retourne un compte /// </summary> /// <param name="compteWeb"></param> /// <returns></returns> public static Compte UtilisateurWebVersCompte(UtilisateurWeb compteWeb) { if (compteWeb.IDWeb == 0) //S'il s'agit d'un nouveau compte. { if (compteWeb.Type) { Medecin CompteMedecin = new Medecin(); CompteMedecin.IDMedecin = compteWeb.IDWeb; CompteMedecin.InfoComplementaire = compteWeb.InfoComplementaire; CompteMedecin.Adresse = compteWeb.Adresse; CompteMedecin.CreePar = compteWeb.CreePar; CompteMedecin.DateCreation = ConvertionDate.ConvertionDateTimeVersString(DateTime.Now); CompteMedecin.DernierModif = ConvertionDate.ConvertionDateTimeVersString(DateTime.Now); CompteMedecin.Identifiant = compteWeb.Identifiant; CompteMedecin.MotDePass = compteWeb.MotDePass; CompteMedecin.Nom = compteWeb.Nom; CompteMedecin.Prenom = compteWeb.Prenom; CompteMedecin.Telephone = compteWeb.Telephone; CompteMedecin.AdresseMail = compteWeb.AdresseMail; CompteMedecin.HoraireOuverture = compteWeb.HoraireOuverture; CompteMedecin.Token = compteWeb.Token; return(CompteMedecin); } else { Patient retourPatient = new Patient(); retourPatient.IDPatient = compteWeb.IDWeb; retourPatient.Adresse = compteWeb.Adresse; retourPatient.CreePar = compteWeb.CreePar; retourPatient.DateCreation = ConvertionDate.ConvertionDateTimeVersString(DateTime.Now); retourPatient.DateNaissance = ConvertionDate.ConvertionStringVersDateTime(compteWeb.DateNaissance); retourPatient.DernierModif = ConvertionDate.ConvertionDateTimeVersString(DateTime.Now); retourPatient.Identifiant = compteWeb.Identifiant; retourPatient.MesMedecin = null; retourPatient.MotDePass = compteWeb.MotDePass; retourPatient.Nom = compteWeb.Nom; retourPatient.Prenom = compteWeb.Prenom; retourPatient.Sexe = compteWeb.Sexe; retourPatient.Telephone = compteWeb.Telephone; retourPatient.TelephonePortable = compteWeb.TelephonePortable; retourPatient.AdresseMail = compteWeb.AdresseMail; retourPatient.Token = compteWeb.Token; return(retourPatient); } } if (new MedecinDAO().IsMedecin(compteWeb.IDWeb)) // si le compte en création est un Medecin { Medecin CompteMedecin = new Medecin(); CompteMedecin.IDMedecin = compteWeb.IDWeb; CompteMedecin.InfoComplementaire = compteWeb.InfoComplementaire; CompteMedecin.Adresse = compteWeb.Adresse; CompteMedecin.CreePar = compteWeb.CreePar; CompteMedecin.DateCreation = ConvertionDate.ConvertionDateTimeVersString(DateTime.Now); CompteMedecin.DernierModif = ConvertionDate.ConvertionDateTimeVersString(DateTime.Now); CompteMedecin.Identifiant = compteWeb.Identifiant; CompteMedecin.MotDePass = compteWeb.MotDePass; CompteMedecin.Nom = compteWeb.Nom; CompteMedecin.Prenom = compteWeb.Prenom; CompteMedecin.Telephone = compteWeb.Telephone; CompteMedecin.AdresseMail = compteWeb.AdresseMail; CompteMedecin.HoraireOuverture = compteWeb.HoraireOuverture; CompteMedecin.Token = compteWeb.Token; return(CompteMedecin); } if (new PatientDAO().IsPatient(compteWeb.IDWeb)) // si le compte en création est un Patient { Patient retourPatient = new Patient(); retourPatient.IDPatient = compteWeb.IDWeb; retourPatient.Adresse = compteWeb.Adresse; retourPatient.CreePar = compteWeb.CreePar; retourPatient.DateCreation = ConvertionDate.ConvertionDateTimeVersString(DateTime.Now); retourPatient.DateNaissance = ConvertionDate.ConvertionStringVersDateTime(compteWeb.DateNaissance); retourPatient.DernierModif = ConvertionDate.ConvertionDateTimeVersString(DateTime.Now); retourPatient.Identifiant = compteWeb.Identifiant; retourPatient.MesMedecin = null; retourPatient.MotDePass = compteWeb.MotDePass; retourPatient.Nom = compteWeb.Nom; retourPatient.Prenom = compteWeb.Prenom; retourPatient.Sexe = compteWeb.Sexe; retourPatient.Telephone = compteWeb.Telephone; retourPatient.TelephonePortable = compteWeb.TelephonePortable; retourPatient.AdresseMail = compteWeb.AdresseMail; retourPatient.Token = compteWeb.Token; return(retourPatient); } else { throw new UtilisateurWebInexistantException("Ce compte n'existe pas", compteWeb); } }