List of usage examples for org.springframework.security.web.savedrequest RequestCache removeRequest
void removeRequest(HttpServletRequest request, HttpServletResponse response);
From source file:cec.easyshop.storefront.security.StorefrontAuthenticationSuccessHandler.java
@Override public void onAuthenticationSuccess(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws IOException, ServletException { //if redirected from some specific url, need to remove the cachedRequest to force use defaultTargetUrl final RequestCache requestCache = new HttpSessionRequestCache(); final SavedRequest savedRequest = requestCache.getRequest(request, response); for (final String redirectUrlForceDefaultTarget : getListRedirectUrlsForceDefaultTarget()) { if (savedRequest != null && savedRequest.getRedirectUrl().contains(redirectUrlForceDefaultTarget)) { requestCache.removeRequest(request, response); break; }//from w w w . j a va2 s. c o m } getCustomerFacade().loginSuccess(); request.setAttribute(CART_MERGED, Boolean.FALSE); if (!getCartFacade().hasEntries()) { getSessionService().setAttribute(WebConstants.CART_RESTORATION_SHOW_MESSAGE, Boolean.TRUE); try { getSessionService().setAttribute(WebConstants.CART_RESTORATION, getCartFacade().restoreSavedCart(null)); } catch (final CommerceCartRestorationException e) { getSessionService().setAttribute(WebConstants.CART_RESTORATION_ERROR_STATUS, WebConstants.CART_RESTORATION_ERROR_STATUS); } } else { final String sessionCartGuid = getCartFacade().getSessionCartGuid(); final String mostRecentSavedCartGuid = getMostRecentSavedCartGuid(sessionCartGuid); if (StringUtils.isNotEmpty(mostRecentSavedCartGuid)) { getSessionService().setAttribute(WebConstants.CART_RESTORATION_SHOW_MESSAGE, Boolean.TRUE); try { getSessionService().setAttribute(WebConstants.CART_RESTORATION, getCartFacade().restoreCartAndMerge(mostRecentSavedCartGuid, sessionCartGuid)); request.setAttribute(CART_MERGED, Boolean.TRUE); } catch (final CommerceCartRestorationException e) { getSessionService().setAttribute(WebConstants.CART_RESTORATION_ERROR_STATUS, WebConstants.CART_RESTORATION_ERROR_STATUS); } catch (final CommerceCartMergingException e) { LOG.error("User saved cart could not be merged"); } } } getBruteForceAttackCounter().resetUserCounter(getCustomerFacade().getCurrentCustomerUid()); super.onAuthenticationSuccess(request, response, authentication); }
From source file:de.hybris.platform.acceleratorstorefrontcommons.security.StorefrontAuthenticationSuccessHandler.java
@Override public void onAuthenticationSuccess(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws IOException, ServletException { //if redirected from some specific url, need to remove the cachedRequest to force use defaultTargetUrl final RequestCache requestCache = new HttpSessionRequestCache(); final SavedRequest savedRequest = requestCache.getRequest(request, response); if (savedRequest != null) { for (final String redirectUrlForceDefaultTarget : getListRedirectUrlsForceDefaultTarget()) { if (savedRequest.getRedirectUrl().contains(redirectUrlForceDefaultTarget)) { requestCache.removeRequest(request, response); break; }//from ww w .jav a2s . c o m } } getCustomerFacade().loginSuccess(); request.setAttribute(WebConstants.CART_MERGED, Boolean.FALSE); // Check if the user is in role admingroup if (!isAdminAuthority(authentication)) { getCartRestorationStrategy().restoreCart(request); getBruteForceAttackCounter().resetUserCounter(getCustomerFacade().getCurrentCustomerUid()); super.onAuthenticationSuccess(request, response, authentication); } else { LOG.warn("Invalidating session for user in the " + Constants.USER.ADMIN_USERGROUP + " group"); invalidateSession(request, response); } }
From source file:de.hybris.platform.b2bacceleratoraddon.security.B2BStorefrontAuthenticationSuccessHandler.java
@Override public void onAuthenticationSuccess(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws IOException, ServletException { //if redirected from some specific url, need to remove the cachedRequest to force use defaultTargetUrl final RequestCache requestCache = new HttpSessionRequestCache(); final SavedRequest savedRequest = requestCache.getRequest(request, response); if (savedRequest != null) { for (final String redirectUrlForceDefaultTarget : getListRedirectUrlsForceDefaultTarget()) { if (savedRequest.getRedirectUrl().contains(redirectUrlForceDefaultTarget)) { requestCache.removeRequest(request, response); break; }//ww w . ja v a 2 s.c o m } } getCustomerFacade().loginSuccess(); request.setAttribute(CART_MERGED, Boolean.FALSE); // Check if the user is in role admingroup if (!isAdminAuthority(authentication)) { if (!getCartFacade().hasEntries()) { restoreSavedCart(); } else { restoreSavedCartAndMerge(request); } getBruteForceAttackCounter().resetUserCounter(getCustomerFacade().getCurrentCustomerUid()); super.onAuthenticationSuccess(request, response, authentication); } else { LOG.warn("Invalidating session for user in the " + Constants.USER.ADMIN_USERGROUP + " group"); invalidateSession(request, response); } }