Advertisement
Guest User

Untitled

a guest
Mar 8th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. package com.sdi.presentation;
  2.  
  3. import java.io.Serializable;
  4. import java.util.Map;
  5.  
  6. import javax.faces.bean.ManagedBean;
  7. import javax.faces.bean.SessionScoped;
  8. import javax.faces.context.FacesContext;
  9.  
  10. import com.sdi.infrastructure.Factories;
  11. import com.sdi.model.Alumno;
  12. import com.sdi.model.User;
  13.  
  14. @ManagedBean(name = "login")
  15. @SessionScoped
  16. public class BeanLogin extends Alumno implements Serializable {
  17. private static final long serialVersionUID = 6L;
  18.  
  19. private String name = "";
  20. private String password = "";
  21. private String result = "login_form_result_valid";
  22.  
  23. public BeanLogin() {
  24. System.out.println("BeanLogin - No existia");
  25. }
  26.  
  27. public String verify() {
  28. LoginService login = Factories.services.createLoginService();
  29. User user = login.verify(name, password);
  30. if (user != null) {
  31. putUserInSession(user);
  32. return "exito";
  33. }
  34. setResult("login_form_result_error");
  35. return "fallo";
  36. }
  37.  
  38. private void putUserInSession(User user) {
  39. Map<String, Object> session = FacesContext
  40. .getCurrentInstance()
  41. .getExternalContext()
  42. .getSessionMap();
  43. session.put("LOGGEDIN_USER", user);
  44. }
  45.  
  46. public String getName() {
  47. return name;
  48. }
  49.  
  50. public void setName(String name) {
  51. this.name = name;
  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 String getResult() {
  63. return result;
  64. }
  65.  
  66. public void setResult(String result) {
  67. this.result = result;
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement