List of usage examples for org.springframework.security.web.savedrequest HttpSessionRequestCache HttpSessionRequestCache
HttpSessionRequestCache
From source file:com.hp.autonomy.frontend.find.hod.beanconfiguration.InMemoryHodSecurity.java
@SuppressWarnings("ProhibitedExceptionDeclared") @Override// w ww .ja v a2 s . c o m protected void configure(final HttpSecurity http) throws Exception { final AuthenticationSuccessHandler loginSuccessHandler = new LoginSuccessHandler(FindRole.CONFIG.toString(), FindController.CONFIG_PATH, "/p/"); final HttpSessionRequestCache requestCache = new HttpSessionRequestCache(); requestCache.setRequestMatcher(new OrRequestMatcher(new AntPathRequestMatcher("/p/**"), new AntPathRequestMatcher(FindController.CONFIG_PATH))); http.regexMatcher("/p/.*|/config/.*|/authenticate|/logout").authorizeRequests().antMatchers("/p/**") .hasRole(FindRole.ADMIN.name()).antMatchers(FindController.CONFIG_PATH) .hasRole(FindRole.CONFIG.name()).and().requestCache().requestCache(requestCache).and().formLogin() .loginPage(FindController.DEFAULT_LOGIN_PAGE).loginProcessingUrl("/authenticate") .successHandler(loginSuccessHandler).failureUrl(FindController.DEFAULT_LOGIN_PAGE + "?error=auth") .and().logout() .logoutSuccessHandler(new HodLogoutSuccessHandler( new HodTokenLogoutSuccessHandler(SsoController.SSO_LOGOUT_PAGE, tokenRepository), FindController.APP_PATH)) .and().csrf().disable(); }
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; }// w w w. j a v a 2 s .co 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; }/* w w w.ja v a 2 s . 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; }/*www . j ava 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); } }
From source file:org.glassmaker.spring.oauth.OAuth2AuthenticationFilter.java
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException { SavedRequest savedRequest = new HttpSessionRequestCache().getRequest(request, response); if (savedRequest == null) { return;/* w w w . j ava 2 s . co m*/ } HttpSession session = request.getSession(); session.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION); // Use the DefaultSavedRequest URL String targetUrl = savedRequest.getRedirectUrl(); logger.debug("Redirecting to DefaultSavedRequest Url: " + targetUrl); response.sendRedirect(targetUrl); }
From source file:com.kdubb.socialshowcaseboot.config.SocialConfig.java
@Bean public ProviderSignInController providerSignInController(ConnectionFactoryLocator connectionFactoryLocator, UsersConnectionRepository usersConnectionRepository) { return new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, new SimpleSignInAdapter(new HttpSessionRequestCache())); }
From source file:architecture.user.spring.config.SecurityConfig.java
@Bean(name = "authenticationRequestCache") public HttpSessionRequestCache authenticationRequestCache() { HttpSessionRequestCache authenticationRequestCache = new HttpSessionRequestCache(); authenticationRequestCache.setRequestMatcher(nonAjaxRequestMatcher()); return authenticationRequestCache; }
From source file:it.infn.mw.iam.config.saml.SamlConfig.java
@Bean public AuthenticationSuccessHandler samlAuthenticationSuccessHandler() { RootIsDashboardSuccessHandler sa = new RootIsDashboardSuccessHandler(iamProperties.getBaseUrl(), new HttpSessionRequestCache()); EnforceAupSignatureSuccessHandler aup = new EnforceAupSignatureSuccessHandler(sa, aupSignatureCheckService, accountUtils, repo);//from w ww. j a v a 2 s . c om return new ExternalAuthenticationSuccessHandler(aup, "/"); }