Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * TransPain SA vous pr�sente son projet de gestion de Projet de D�veloppement Logiciel
- * Copyleft 2016 TransPain.
- * /\_/\
- * =( °w° )=
- * ) ( //
- * (__ __)//
- */
- package ch.translait.transpain.presentation.bean;
- import ch.translait.transpain.services.AuthServicesImpl;
- import java.io.IOException;
- import javax.faces.bean.ManagedBean;
- import javax.faces.context.FacesContext;
- import javax.servlet.http.HttpSession;
- import javax.faces.bean.SessionScoped;
- /**
- *
- * @author JulmyS
- */
- @ManagedBean(name = "loginManagedBean")
- @SessionScoped
- public class LoginManagedBean {
- private String username;
- private String password;
- public LoginManagedBean() {
- }
- public String checkPassword() {
- String returnStatement = "false";
- boolean loginOk = new AuthServicesImpl().checkLogin(username, password);
- AuthServicesImpl auth = new AuthServicesImpl();
- if (auth.checkLogin(username, password)) {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(true);
- session.setAttribute("username", username);
- returnStatement = "true";
- }
- return returnStatement;
- }
- public String getUsername() {
- return username;
- }
- public void setUsername(String username) {
- this.username = username;
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- public void logout() throws IOException {
- HttpSession session = SessionManagedBean.getSession();
- session.invalidate();
- FacesContext.getCurrentInstance().getExternalContext().redirect("/faces/login.xhtml");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement