Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 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 java.io.IOException;
  13. import javax.faces.bean.ManagedBean;
  14. import javax.faces.context.FacesContext;
  15. import javax.servlet.http.HttpSession;
  16. import javax.faces.bean.SessionScoped;
  17.  
  18. /**
  19. *
  20. * @author JulmyS
  21. */
  22. @ManagedBean(name = "loginManagedBean")
  23. @SessionScoped
  24. public class LoginManagedBean {
  25.  
  26. private String username;
  27. private String password;
  28.  
  29.  
  30. public LoginManagedBean() {
  31. }
  32.  
  33. public String checkPassword() {
  34. String returnStatement = "false";
  35. boolean loginOk = new AuthServicesImpl().checkLogin(username, password);
  36. AuthServicesImpl auth = new AuthServicesImpl();
  37. if (auth.checkLogin(username, password)) {
  38. FacesContext facesContext = FacesContext.getCurrentInstance();
  39. HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(true);
  40. session.setAttribute("username", username);
  41. returnStatement = "true";
  42. }
  43. return returnStatement;
  44. }
  45.  
  46. public String getUsername() {
  47. return username;
  48. }
  49.  
  50. public void setUsername(String username) {
  51. this.username = username;
  52. }
  53.  
  54. public String getPassword() {
  55. return password;
  56. }
  57.  
  58. public void setPassword(String password) {
  59. this.password = password;
  60. }
  61.  
  62. public void logout() throws IOException {
  63. HttpSession session = SessionManagedBean.getSession();
  64. session.invalidate();
  65. FacesContext.getCurrentInstance().getExternalContext().redirect("/faces/login.xhtml");
  66. }
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement