Advertisement
kugelbergerer

Untitled

Jan 9th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. package UserSession;
  2.  
  3. import java.io.Serializable;
  4.  
  5. import javax.enterprise.context.SessionScoped;
  6.  
  7. @SessionScoped
  8. public class C_UserSession implements Serializable {
  9.  
  10. private static final long serialVersionUID = 1L;
  11. private String userId;
  12.  
  13. public C_UserSession() {
  14. }
  15.  
  16. public void setUserId(String userId) {
  17. this.userId = userId;
  18. }
  19.  
  20. public String getUserId() {
  21. return userId;
  22. }
  23. }
  24.  
  25.  
  26.  
  27. ################ I_Login
  28.  
  29.  
  30.  
  31. public interface I_Login {
  32.  
  33. public boolean login (String username, String password);
  34. }
  35.  
  36.  
  37.  
  38. ########## C_Login
  39.  
  40.  
  41. package UserSession;
  42.  
  43. import javax.inject.Inject;
  44.  
  45. import Adminpage.M_User_JSF;
  46.  
  47. public class C_Login {
  48.  
  49. @Inject
  50. I_Userrepo userrepo;
  51.  
  52. @Inject
  53. C_UserSession currentuser;
  54.  
  55. public boolean login (String username, String password){
  56. M_User_JSF user = userrepo.getuser(username);
  57.  
  58. if( user == null ) {
  59. currentuser.setUserId( null );
  60. return false;
  61. }
  62. if( user.getPasswort().equals( password ) == false ) {
  63. currentuser.setUserId( null );
  64. return false;
  65. }
  66. currentuser.setUserId( username );
  67. return true;
  68. }
  69.  
  70. }
  71.  
  72.  
  73.  
  74.  
  75. ################## I_Userrepo
  76.  
  77.  
  78.  
  79. import Adminpage.M_User_JSF;
  80.  
  81. public interface I_Userrepo {
  82.  
  83. public M_User_JSF getuser (String username);
  84. }
  85.  
  86.  
  87.  
  88. ##############
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement