List of usage examples for javax.servlet.http HttpServletRequest getSession
public HttpSession getSession();
From source file:com.salesmanager.core.util.LocaleUtil.java
public static void setLocale(HttpServletRequest req, Locale locale) { req.getSession().setAttribute("WW_TRANS_I18N_LOCALE", locale); }
From source file:com.formkiq.core.webflow.FlowManager.java
/** * Gets the Next WebFlow Session Id.// w ww .ja v a 2 s. c o m * @param req {@link HttpServletRequest} * @return int */ private static int getNextWebFlowSessionId(final HttpServletRequest req) { int sessionId = 1; HttpSession session = req.getSession(); Object sessionOb = session.getAttribute(WEBFLOW_SESSION_ID); if (sessionOb != null) { try { sessionId = Integer.parseInt(sessionOb.toString()) + 1; } catch (NumberFormatException e) { sessionId = 1; } } session.setAttribute(WEBFLOW_SESSION_ID, String.valueOf(sessionId)); return sessionId; }
From source file:com.eryansky.common.web.utils.upload.FileUploadUtils.java
/** * ??? //from w w w . ja v a 2 s.c om * * @param request * @return */ public static final String extractUploadDir(HttpServletRequest request) { return request.getSession().getServletContext().getRealPath("/"); }
From source file:eu.europa.ejusticeportal.dss.controller.action.NewSealMethodTest.java
private static HttpServletRequest getRequest() { HttpServletRequest r = Mockito.mock(HttpServletRequest.class); HttpSession session = Mockito.mock(HttpSession.class); Mockito.when(r.getSession()).thenReturn(session); return r;// www. j a v a 2 s .com }
From source file:com.salesmanager.central.util.SecurityUtil.java
/** * Determines if a user has roles for seeing / modifying the appropriate resource * @param request//from ww w.ja va2 s . c o m * @param role * @return */ public static boolean isUserInRole(HttpServletRequest request, String role) { try { if (StringUtils.isBlank(role)) { return true; } UserPrincipal principal = (UserPrincipal) request.getSession().getAttribute("PRINCIPAL"); if (principal == null) { return false; } Context ctx = (Context) request.getSession().getAttribute(ProfileConstants.context); if (ctx.getMasterRole().equals("superuser")) { return true; } if (role.equals("superuser")) { if (ctx.getMasterRole().equals("superuser")) { return true; } } else { if (ctx.getMasterRole().equals("admin")) { return true; } } if (ctx.getMasterRole().equals("admin")) { return true; } return com.salesmanager.core.util.SecurityUtil.isUserInRole(request, role); } catch (Exception e) { log.error("Customer " + e); } return false; }
From source file:edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean.java
/** * Remove the login process bean from the session. If there is no bean, do * nothing./*from w w w . ja v a 2 s . c o m*/ */ public static void removeBean(HttpServletRequest request) { if (isBean(request)) { request.getSession().removeAttribute(SESSION_ATTRIBUTE); } }
From source file:com.nabla.wapp.server.general.UserSession.java
public static String save(final HttpServletRequest request, final Integer userId, final String userName, final String locale) { final UserSession session = new UserSession(userId, IRootUser.NAME.equalsIgnoreCase(userName), locale); request.getSession().setAttribute(SESSION_PARAMETER_NAME, session); return session.getSessionId(); }
From source file:edu.cornell.mannlib.vitro.webapp.controller.MultipartRequestWrapper.java
/** * Find the temporary storage directory for this webapp. *///from w ww. jav a2s .c o m private static File figureTemporaryDirectory(HttpServletRequest request) { return (File) request.getSession().getServletContext().getAttribute("javax.servlet.context.tempdir"); }
From source file:egovframework.com.ext.jfile.session.SessionUploadChecker.java
public static void check(HttpServletRequest request, String fileId) { log.debug(new StringBuilder().append("\n").append("\n") .append("================== session upload check ==================").append("\n") .append(" jsessionid_fileId : ").append(request.getSession().getId()).append("\n") .append("==========================================================").append("\n").toString()); sessionMap.put(request.getSession().getId() + "_" + fileId, true); }
From source file:edu.cornell.mannlib.vitro.webapp.i18n.selection.SelectedLocale.java
/** * Store the selected locale in the current session. */// w w w . j av a 2 s. com public static void setSelectedLocale(HttpServletRequest req, Locale selectedLocale) { log.debug("Set selected locale: " + selectedLocale); req.getSession().setAttribute(ATTRIBUTE_NAME, new SessionSelectedLocale(selectedLocale)); }