Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. /*
  2. * TransPain SA vous pr�sente son projet de gestion de Projet de D�veloppement Logiciel
  3. * Copyleft 2016 TransPain.
  4. * /\_/\
  5. * =( °w° )=
  6. * ) ( //
  7. * (__ __)//
  8. */
  9. package ch.translait.transpain.presentation.bean;
  10.  
  11. import ch.translait.transpain.services.AuthServicesImpl;
  12. import javax.faces.bean.ManagedBean;
  13. import javax.faces.context.FacesContext;
  14. import javax.servlet.http.HttpSession;
  15. import javax.faces.bean.SessionScoped;
  16.  
  17. /**
  18. *
  19. * @author JulmyS
  20. */
  21. @ManagedBean(name = "loginManagedBean")
  22. @SessionScoped
  23. public class LoginManagedBean {
  24.  
  25. private String username;
  26. private String password;
  27.  
  28.  
  29. public LoginManagedBean() {
  30. }
  31.  
  32. public String checkPassword() {
  33. String returnStatement = "false";
  34. boolean loginOk = new AuthServicesImpl().checkLogin(username, password);
  35. AuthServicesImpl auth = new AuthServicesImpl();
  36. if (auth.checkLogin(username, password)) {
  37. FacesContext facesContext = FacesContext.getCurrentInstance();
  38. HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(true);
  39. session.setAttribute("username", username);
  40. returnStatement = "true";
  41. }
  42. return returnStatement;
  43. }
  44.  
  45. public String getUsername() {
  46. return username;
  47. }
  48.  
  49. public void setUsername(String username) {
  50. this.username = username;
  51. }
  52.  
  53. public String getPassword() {
  54. return password;
  55. }
  56.  
  57. public void setPassword(String password) {
  58. this.password = password;
  59. }
  60.  
  61. public void logout() {
  62. HttpSession session = SessionManagedBean.getSession();
  63. session.invalidate();
  64. FacesContext.getCurrentInstance().getExternalContext().redirect("/faces/login.xhtml");
  65. }
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement