public String redirect(HttpServletRequest request, HttpServletResponse response, Model model) { String path = null; if (BLCRequestUtils.isOKtoUseSession(new ServletWebRequest(request))) { path = (String) request.getSession().getAttribute("BLC_REDIRECT_URL"); } if (path == null) { path = request.getContextPath(); } return "ajaxredirect:" + path; } }
public String getRequestURIWithoutContext() { return BLCRequestUtils.getRequestURIWithoutContext(request); }
@Override public void process(WebRequest request) { if (request instanceof ServletWebRequest) { ServletWebRequest servletWebRequest = (ServletWebRequest) request; Map proxy = (Map) BLCRequestUtils.getSessionAttributeIfOk(request, COOKIE_ATTRIBUTE_NAME); if (proxy == null) { proxy = getVals(servletWebRequest); BLCRequestUtils.setSessionAttributeIfOk(request, COOKIE_ATTRIBUTE_NAME, proxy); } BroadleafRequestContext.getBroadleafRequestContext().getAdditionalProperties().put(COOKIE_ATTRIBUTE_NAME, proxy); Map<String, Object> ruleMap = getRuleMapFromRequest(request); ruleMap.put(COOKIE_ATTRIBUTE_NAME, proxy); request.setAttribute(BLC_RULE_MAP_PARAM, ruleMap, WebRequest.SCOPE_REQUEST); } }
if (timeZone == null && BLCRequestUtils.getURLorHeaderParameter(request, TIMEZONE_CODE_PARAM) != null) { String timeZoneCode = BLCRequestUtils.getURLorHeaderParameter(request, TIMEZONE_CODE_PARAM); timeZone = TimeZone.getTimeZone(timeZoneCode); if (timeZone == null && BLCRequestUtils.isOKtoUseSession(request)) { if (BLCRequestUtils.isOKtoUseSession(request)) { request.setAttribute(TIMEZONE_VAR, timeZone, WebRequest.SCOPE_GLOBAL_SESSION);
Customer customer = null; Long overrideId = null; if (BLCRequestUtils.isOKtoUseSession(request)) { overrideId = (Long) request.getAttribute(OVERRIDE_CUSTOMER_SESSION_ATTR_NAME, WebRequest.SCOPE_GLOBAL_SESSION); String lastPublishedEventClass = (String) BLCRequestUtils.getSessionAttributeIfOk(request, LAST_PUBLISHED_EVENT_CLASS_SESSION_ATTRIBUTE_NAME); String eventUsername = (String) BLCRequestUtils.getSessionAttributeIfOk(request, LAST_PUBLISHED_EVENT_USERNAME_SESSION_ATTRIBUTE_NAME);
protected void publishEvent(ApplicationEvent event, WebRequest request, String eventClass, String username) { eventPublisher.publishEvent(event); BLCRequestUtils.setSessionAttributeIfOk(request, LAST_PUBLISHED_EVENT_CLASS_SESSION_ATTRIBUTE_NAME, eventClass); BLCRequestUtils.setSessionAttributeIfOk(request, LAST_PUBLISHED_EVENT_USERNAME_SESSION_ATTRIBUTE_NAME, username); }
protected boolean isIgnored(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { boolean isUriSecurityIgnored = BLCRequestUtils.isFilteringIgnoredForUri(new ServletWebRequest(httpServletRequest, httpServletResponse)); return isUriSecurityIgnored; }
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { if (springSecurity != null) { List<SecurityFilterChain> securityChains = springSecurity.getFilterChains(); for (SecurityFilterChain chain : securityChains) { if (chain.matches((HttpServletRequest) request) && chain.getFilters().isEmpty()) { BLCRequestUtils.setIsFilteringIgnoredForUri(new ServletWebRequest((HttpServletRequest) request, (HttpServletResponse) response), Boolean.TRUE); break; } } } filterChain.doFilter(request, response); }
if (locale == null && BLCRequestUtils.getURLorHeaderParameter(request, LOCALE_CODE_PARAM) != null) { String localeCode = BLCRequestUtils.getURLorHeaderParameter(request, LOCALE_CODE_PARAM); locale = localeService.findLocaleByCode(localeCode); if (BLCRequestUtils.isOKtoUseSession(request)) { request.removeAttribute(BroadleafCurrencyResolverImpl.CURRENCY_VAR, WebRequest.SCOPE_GLOBAL_SESSION); if (locale == null && BLCRequestUtils.isOKtoUseSession(request)) { locale = (Locale) request.getAttribute(LOCALE_VAR, WebRequest.SCOPE_GLOBAL_SESSION); if (LOG.isTraceEnabled()) { if (BLCRequestUtils.isOKtoUseSession(request)) { request.removeAttribute(BroadleafCurrencyResolverImpl.CURRENCY_VAR, WebRequest.SCOPE_GLOBAL_SESSION); request.setAttribute(CookieLocaleResolver.LOCALE_REQUEST_ATTRIBUTE_NAME, javaLocale, WebRequest.SCOPE_REQUEST); if (BLCRequestUtils.isOKtoUseSession(request)) { request.setAttribute(LOCALE_VAR, locale, WebRequest.SCOPE_GLOBAL_SESSION);
Customer customer = null; Long overrideId = null; if (BLCRequestUtils.isOKtoUseSession(request)) { overrideId = (Long) request.getAttribute(OVERRIDE_CUSTOMER_SESSION_ATTR_NAME, WebRequest.SCOPE_GLOBAL_SESSION); String lastPublishedEventClass = (String) BLCRequestUtils.getSessionAttributeIfOk(request, LAST_PUBLISHED_EVENT_CLASS_SESSION_ATTRIBUTE_NAME); String eventUsername = (String) BLCRequestUtils.getSessionAttributeIfOk(request, LAST_PUBLISHED_EVENT_USERNAME_SESSION_ATTRIBUTE_NAME);
protected void publishEvent(ApplicationEvent event, WebRequest request, String eventClass, String username) { eventPublisher.publishEvent(event); BLCRequestUtils.setSessionAttributeIfOk(request, LAST_PUBLISHED_EVENT_CLASS_SESSION_ATTRIBUTE_NAME, eventClass); BLCRequestUtils.setSessionAttributeIfOk(request, LAST_PUBLISHED_EVENT_USERNAME_SESSION_ATTRIBUTE_NAME, username); }
protected boolean isIgnored(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { boolean isUriSecurityIgnored = BLCRequestUtils.isFilteringIgnoredForUri(new ServletWebRequest(httpServletRequest, httpServletResponse)); return isUriSecurityIgnored; }
/** * Takes {@link #isOKtoUseSession(WebRequest)} into account when retrieving session attributes. If it's not ok, this * will return null */ public static Object getSessionAttributeIfOk(WebRequest request, String attribute) { if (isOKtoUseSession(request)) { return request.getAttribute(attribute, WebRequest.SCOPE_GLOBAL_SESSION); } return null; }
if (desiredCurrency == null && BLCRequestUtils.getURLorHeaderParameter(request, CURRENCY_CODE_PARAM) != null) { String currencyCode = BLCRequestUtils.getURLorHeaderParameter(request, CURRENCY_CODE_PARAM); desiredCurrency = broadleafCurrencyService.findCurrencyByCode(currencyCode); if (LOG.isTraceEnabled()) { if (desiredCurrency == null && BLCRequestUtils.isOKtoUseSession(request)) { desiredCurrency = (BroadleafCurrency) request.getAttribute(CURRENCY_VAR, WebRequest.SCOPE_GLOBAL_SESSION); if (BLCRequestUtils.isOKtoUseSession(request)) { request.setAttribute(CURRENCY_VAR, currencyToUse, WebRequest.SCOPE_GLOBAL_SESSION);
@Override public void process(WebRequest request) { if (isGeolocationEnabled()) { if (request instanceof ServletWebRequest) { ServletWebRequest servletWebRequest = (ServletWebRequest) request; GeolocationDTO location = (GeolocationDTO) BLCRequestUtils.getSessionAttributeIfOk(request, GEOLOCATON_ATTRIBUTE_NAME); if (location == null) { String ipAddress = getIPAddress(servletWebRequest); location = geolocationService.getLocationData(ipAddress); BLCRequestUtils.setSessionAttributeIfOk(request, GEOLOCATON_ATTRIBUTE_NAME, location); } BroadleafRequestContext.getBroadleafRequestContext().getAdditionalProperties().put(GEOLOCATON_ATTRIBUTE_NAME, location); Map<String, Object> ruleMap = getRuleMapFromRequest(request); ruleMap.put(GEOLOCATON_ATTRIBUTE_NAME, location); request.setAttribute(BLC_RULE_MAP_PARAM, ruleMap, WebRequest.SCOPE_REQUEST); } } }
protected Category findCategoryUsingUrl(HttpServletRequest request) throws UnsupportedEncodingException { String requestUri = URLDecoder.decode(BLCRequestUtils.getRequestURIWithoutContext(request), charEncoding); Category category = catalogService.findCategoryByURI(requestUri); if (category != null && LOG.isDebugEnabled()) { LOG.debug("Obtained the category using URI=" + requestUri); } return category; }
protected boolean isIgnored(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { boolean isUriSecurityIgnored = BLCRequestUtils.isFilteringIgnoredForUri(new ServletWebRequest(httpServletRequest, httpServletResponse)); return isUriSecurityIgnored; }
/** * Takes {@link #isOKtoUseSession(WebRequest)} into account when setting a session attribute * * @return <b>true</b> if this set the session attribute, <b>false</b> otherwise */ public static boolean setSessionAttributeIfOk(WebRequest request, String attribute, Object value) { if (isOKtoUseSession(request)) { request.setAttribute(attribute, value, WebRequest.SCOPE_GLOBAL_SESSION); return true; } return false; }
protected Product findProductUsingUrl(HttpServletRequest request) throws UnsupportedEncodingException { String requestUri = URLDecoder.decode(BLCRequestUtils.getRequestURIWithoutContext(request), charEncoding); Product product = catalogService.findProductByURI(requestUri); if (product != null && LOG.isDebugEnabled()) { LOG.debug("Obtained the product using URI=" + requestUri); } return product; }
@Override public void invalidateState(boolean notify) { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); if (BLCRequestUtils.isOKtoUseSession(new ServletWebRequest(request))) { HttpSession session = request.getSession(); session.removeAttribute(STATEVERSIONTOKEN); if (notify) { getStateVersionToken(); request.setAttribute(STATECHANGENOTIFICATIONTOKEN, "true"); } } }