private List<Filter> addFilters(MotechURLSecurityRule securityRule) throws ServletException { List<Filter> filters = new ArrayList<>(); SecurityContextRepository contextRepository = new HttpSessionSecurityContextRepository(); RequestCache requestCache = new HttpSessionRequestCache(); addSecureChannel(filters, securityRule.getProtocol()); addSecurityContextPersistenceFilter(filters, contextRepository); addLogoutFilter(filters, securityRule); addAuthenticationFilters(filters, securityRule); addRequestCacheFilter(filters, requestCache); addSecurityContextHolderAwareRequestFilter(filters); addAnonymousAuthenticationFilter(filters); addSessionManagementFilter(filters, contextRepository); addExceptionTranslationFilter(filters, requestCache, securityRule.isRest()); addFilterSecurityInterceptor(filters, securityRule); return filters; }
@Bean public SignInAdapter signInAdapter(UserDetailsService userDetailsService) { RequestCache requestCache = new HttpSessionRequestCache(); return (userId, connection, request) -> { UserDetails userDetails = userDetailsService.loadUserByUsername(userId); Authentication authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities()); SecurityContextHolder.getContext().setAuthentication(authentication); SavedRequest savedRequest = requestCache.getRequest(request.getNativeRequest(HttpServletRequest.class), request.getNativeResponse(HttpServletResponse.class)); return savedRequest == null ? null : savedRequest.getRedirectUrl(); }; }
public RequestCache getRequestCache() { return requestCache; }
public void setRequestCache(RequestCache requestCache) { this.requestCache = requestCache; }
@Override public void setRequestCache(RequestCache requestCache) { super.setRequestCache(requestCache); }
@Inject public SocialSignInAdapter(RequestCache requestCache) { this.requestCache = requestCache; }
@Inject public SimpleSignInAdapter(RequestCache requestCache) { this.requestCache = requestCache; }
public CookieSavedRequestAwareAuthenticationSuccessHandler(RequestCache requestCache) { setRequestCache(requestCache); }
private void addRequestCacheFilter(List<Filter> filters, RequestCache requestCache) { RequestCacheAwareFilter cacheFilter = new RequestCacheAwareFilter(requestCache); filters.add(cacheFilter); }
@Override public void setRequestCache(RequestCache requestCache) { this.requestCache = requestCache; super.setRequestCache(requestCache); }
/** * Sets the cache where the current request is saved. */ public void setRequestCache(RequestCache requestCache) { this.requestCache = requestCache; }
@Bean public RequestCache requestCache() { return new HttpSessionRequestCache(); }
public void setRequestCache(final RequestCache requestCache) { this.requestCache = requestCache; }
@Inject public AccountSignInAdapter(AccountRepository accountRepository, RequestCache requestCache) { this.accountRepository = accountRepository; this.requestCache = requestCache; }
/** * The Spring MVC Controller that coordinates "sign-in with {provider}" attempts. * @param accountRepository the account repository that can load user Account objects given an account id. */ // @Bean public ProviderSignInController providerSignInController(AccountRepository accountRepository, RequestCache requestCache) { return new ProviderSignInController(connectionFactoryLocator(), usersConnectionRepository(), new AccountSignInAdapter(accountRepository, requestCache)); }
/** * Set a request cache to look for a redirection target if no target URL was provided by a * request parameter. By default a {@link HttpSessionRequestCache} will be used. * * @param requestCache * the cache to use */ public void setRequestCache(RequestCache requestCache) { this.requestCache = requestCache; }
/** * * @param cache - Request cache */ public void setRequestCache(RequestCache cache) { this.requestCache = cache; }