Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.07 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package bean;
  6.  
  7. import adminjsf.MonitorController;
  8. import domain.Monitor;
  9. import javax.ejb.EJB;
  10. import javax.faces.bean.ManagedBean;
  11. import javax.faces.bean.SessionScoped;
  12.  
  13. /**
  14.  * @author
  15.  */
  16. @ManagedBean
  17. @SessionScoped
  18. public class NavigationBean {
  19.  
  20.     private boolean logInFailed = false;
  21.     private boolean loggedIn = false;
  22.     @EJB private adminjsf.MonitorController ejbFacade;
  23.     private Monitor currentMonitor;
  24.     private String username;
  25.     private String password;
  26.  
  27.     /** Creates a new instance of NavigationBean */
  28.     public NavigationBean() {
  29.     }
  30.  
  31.     public boolean isLoggedIn() {
  32.         return loggedIn;
  33.     }
  34.  
  35.     public void setLoggedIn(boolean loggedIn) {
  36.         this.loggedIn = loggedIn;
  37.     }
  38.  
  39.     public Monitor getCurrentMonitor() {
  40.         return currentMonitor;
  41.     }
  42.  
  43.     public void setCurrentMonitor(Monitor currentMonitor) {
  44.         this.currentMonitor = currentMonitor;
  45.     }
  46.  
  47.     public String getPassword() {
  48.         return password;
  49.     }
  50.  
  51.     public void setPassword(String password) {
  52.         this.password = password;
  53.     }
  54.  
  55.     public String getUsername() {
  56.         return username;
  57.     }
  58.  
  59.     public void setUsername(String username) {
  60.         this.username = username;
  61.     }
  62.  
  63.     public boolean isLogInFailed() {
  64.         return logInFailed;
  65.     }
  66.  
  67.     public void setLogInFailed(boolean logInFailed) {
  68.         this.logInFailed = logInFailed;
  69.     }
  70.  
  71.     public String login() {
  72.         String output = null;
  73.         currentMonitor = ejbFacade.getMonitorByName(username);
  74.  
  75.         if (currentMonitor == null) {
  76.             logInFailed = true;
  77.             output = null;
  78.         } else {
  79.             if (currentMonitor.getLogin().equals(password)) {
  80.                 logInFailed = false;
  81.                 output = "WEB-INF/usermanagement.xhtml";
  82.             } else {
  83.                 logInFailed = true;
  84.                 output = null;
  85.             }
  86.         }
  87.         return output;
  88.     }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement