List of usage examples for javax.servlet.http HttpSession getAttribute
public Object getAttribute(String name);
null
if no object is bound under the name. From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.EditSubmission.java
public static void putEditSubmissionInSession(HttpSession sess, EditSubmission editSub) { Map<String, EditSubmission> submissions = (Map<String, EditSubmission>) sess .getAttribute("EditSubmissions"); if (submissions == null) { submissions = new HashMap<String, EditSubmission>(); sess.setAttribute("EditSubmissions", submissions); }/*w ww . j a v a2s. c o m*/ submissions.put(editSub.editKey, editSub); }
From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.EditSubmission.java
public static EditSubmission getEditSubmissionFromSession(HttpSession sess, EditConfiguration editConfig) { Map<String, EditSubmission> submissions = (Map<String, EditSubmission>) sess .getAttribute("EditSubmissions"); if (submissions == null) return null; if (editConfig != null) return submissions.get(editConfig.getEditKey()); //this might be null else//from w w w. j a va2s . c o m return null; }
From source file:com.mnt.base.web.DigestAuthenticator.java
public static boolean authenticate(HttpServletRequest req, HttpServletResponse resp) { boolean result = false; HttpSession session = req.getSession(); if (session != null) { result = session.getAttribute(AUTHENTICATED_FLAG_KEY) != null; if (!result) { session.setMaxInactiveInterval(60); Map<String, Object> authInfoMap = CommonUtil.uncheckedMapCast(session.getAttribute(AUTH_INFO_MAP)); if (authInfoMap == null) { authInfoMap = new HashMap<String, Object>(); session.setAttribute(AUTH_INFO_MAP, authInfoMap); }//from ww w.j a v a2s . c o m String authentication = req.getHeader("Authorization"); if (CommonUtil.isEmpty(authentication) || !authentication.startsWith("Digest ")) { postAuthRequired(req, resp, authInfoMap); } else { result = authenticate(req.getMethod(), authentication, authInfoMap); if (result) { if (authProvider != null) { try { authProvider.authenticated(authUser.get(), true); } catch (Exception e) { log.error("error while invoke the authProvider.authenticated: " + authUser.get(), e); } } session.setAttribute(AUTHENTICATED_FLAG_KEY, true); session.removeAttribute(AUTH_INFO_MAP); authInfoMap.clear(); authInfoMap = null; session.setMaxInactiveInterval(1800); } else { authProvider.authenticated(authUser.get(), false); authInfoMap.clear(); postAuthRequired(req, resp, authInfoMap); } } } } else { System.err.println("Just support session available authentication."); } return result; }
From source file:com.lm.lic.manager.util.GenUtil.java
/** * Get the logged in user/role S/*from w w w . j a v a2 s . co m*/ * * @param request * @return */ public static User getLoggedinUser(ServletRequest request) { HttpServletRequest req = (HttpServletRequest) request; HttpSession session = req.getSession(true); User user = (User) session.getAttribute("user"); return user; }
From source file:fr.paris.lutece.plugins.mylutece.web.MyLuteceApp.java
/** * Returns the current url//from w ww . j a v a 2 s . com * @param request The Http request * @return The current url * */ public static String getCurrentUrl(HttpServletRequest request) { HttpSession session = request.getSession(); String strNextUrl = (String) session.getAttribute(ATTRIBUTE_CURRENT_URL); return strNextUrl; }
From source file:com.lm.lic.manager.util.GenUtil.java
/** * @param request// w ww. j a va2s. c o m * @return */ public static String findProductUnderManagement(HttpServletRequest request) { HttpSession session = request.getSession(); String prodId = (String) session.getAttribute("prodId"); return prodId; }
From source file:com.lm.lic.manager.util.GenUtil.java
/** * @param session//from w ww .ja va 2s.c o m */ public static void invalidateSession(LoginService loginService, HttpSession session) { if (session != null) { User user = (User) session.getAttribute("user"); if (user != null) loginService.makeUserLoggedOut(user, session); session.removeAttribute(GenUtil.LOGGED_IN_ATTRIBUTE); session.invalidate(); } }
From source file:com.opencnc.controllers.ModeloController.java
/** * ***************************************************************************** * Crea los modelos por usuario./*from w w w . j a va 2 s .com*/ * ***************************************************************************** * @param request * @param response * @return * @throws Exception */ @RequestMapping("/modelo/crearModelo") static ModelAndView crearModelo(HttpServletRequest request, HttpServletResponse response) throws Exception { HttpSession sess = request.getSession(); if (sess != null) { Modelo md = new Modelo(); ModelAndView m = new ModelAndView("/modelo/crearModelo"); m.addObject("modelo", md); Session s = HibernateUtil.getSessionFactory().openSession(); //Usuario us = (Usuario)request.getAttribute("usuario"); Usuario us = (Usuario) sess.getAttribute("usuario"); Criteria c = s.createCriteria(TipoMaquina.class); Criteria ma = s.createCriteria(UnidadMedida.class); Criteria user = s.createCriteria(Usuario.class); List<UnidadMedida> lm = ma.list(); List<TipoMaquina> l = c.list(); //List<Usuario> luser = user.list(); Integer luser = us.getUsuarioId(); m.addObject("listaTipoMaquina", l); m.addObject("listaUnidadMedida", lm); m.addObject("listaUsuarios", luser); m.addObject("nombreUsuario", us.getNombre()); //HttpSession session = request.getSession(); //m.addObject("numUsuarioId", us.getUsuarioId()); return m; } else { request.removeAttribute("usuario"); return new ModelAndView("redirect:/usuario/login.htm"); } }
From source file:net.big_oh.common.web.WebUtil.java
/** * /*from ww w . j a v a 2 s.c o m*/ * Calculate an <b>approximation</b> of the memory consumed by the objects * stored under each attribute of a user's {@link HttpSession}. The estimate * will often be greater than the actual value because of "double counting" * objects that appear multiple times in the attribute value's object graph. * * @param session * An HttpSession object from any web application. * @return An <b>approximation</b> of the memory consumed for each attribute * <b>name</b> in the session. */ public static Map<String, Integer> getSessionAttributeNameToApproxSizeInBytesMap(HttpSession session) { // Use an IdentityHashMap because we don't want to miss distinct objects // that are equivalent according to equals(..) method. Map<String, Integer> sessionAttributeNameToApproxSizeInBytesMap = new IdentityHashMap<String, Integer>(); Enumeration<?> enumeration = session.getAttributeNames(); while (enumeration.hasMoreElements()) { String attributeName = (String) enumeration.nextElement(); session.getAttribute(attributeName); try { sessionAttributeNameToApproxSizeInBytesMap.put(attributeName, new Integer(approximateObjectSize(attributeName))); } catch (IOException ioe) { logger.error("Failed to approximate size of session attribute name: " + attributeName.getClass().getName(), ioe); sessionAttributeNameToApproxSizeInBytesMap.put(attributeName, new Integer(0)); } } return sessionAttributeNameToApproxSizeInBytesMap; }
From source file:com.huateng.ebank.business.common.GlobalInfo.java
public static GlobalInfo getFromRequest2(HttpServletRequest request) throws CommonException { HttpSession httpSession = request.getSession(); GlobalInfo globalInfo = (GlobalInfo) httpSession.getAttribute(GlobalInfo.KEY_GLOBAL_INFO); if (log.isDebugEnabled()) { log.debug("session id = " + httpSession.getId()); }/*from w ww. j a v a 2 s . com*/ if (null != globalInfo) { setCurrentInstance(globalInfo); String sessionId = httpSession.getId(); globalInfo.setSessionId(sessionId); } return globalInfo; }