* Filtro AuthorizationFilter para gestionar inicio de sesión. * Interfaz para página de login básica. * Todos los managed beans movidos a paquete managedbean * Configuración básica de faces-config con navegación de paginas outcome. * Actualizado web.xml * Utilización de librería primefaces para interfaz de usuario. * Aplicado tema bootstrap para primefaces. * Los iconos (glyph-icons) de primefaces no se cargan en la interfaz (Pendiente de investigar). * Actualización de projects archives para inclusión de clases nuevas en JAR/WAR/EAR de forma correcta.
42 lines
1.0 KiB
Java
42 lines
1.0 KiB
Java
|
|
package managedbean.common;
|
|
|
|
import javax.faces.context.FacesContext;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpSession;
|
|
|
|
|
|
public class SessionUtils {
|
|
|
|
public static HttpSession getSession() {
|
|
return (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
|
|
}
|
|
|
|
public static HttpServletRequest getRequest() {
|
|
return (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
|
|
}
|
|
|
|
public static boolean isLogedIn() {
|
|
if (getUserId() == "")
|
|
return false;
|
|
else
|
|
return true;
|
|
}
|
|
|
|
public static String getUserName() {
|
|
HttpSession session = getSession();
|
|
if (session != null && session.getAttribute("username") != null)
|
|
return session.getAttribute("username").toString();
|
|
else
|
|
return "";
|
|
}
|
|
|
|
public static String getUserId() {
|
|
HttpSession session = getSession();
|
|
if (session != null && session.getAttribute("userid") != null)
|
|
return session.getAttribute("userid").toString();
|
|
else
|
|
return "";
|
|
}
|
|
}
|