@Bean @Autowired public SecurityContextRepository securityContextRepository(JwtSecurityTokenService jwtTokenService){ JwtSecurityContextRepository jwt = new JwtSecurityContextRepository(); jwt.setJwtTokenService(jwtTokenService); String authName = securityConfig.getJwt().getAuthKey(); if(StringUtils.isBlank(authName)){ authName = securityConfig.getJwt().getAuthHeader(); } jwt.setAuthHeaderName(authName); jwt.setAuthStore(securityConfig.getJwt().getAuthStore()); jwt.setCookieStorer(CookieStorer.builder() .cookieDomain(securityConfig.getCookie().getDomain()) .cookiePath(securityConfig.getCookie().getPath()) .build()); return jwt; }
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; }
@Override public Action inspect(AtmosphereResource r) { final SecurityContextRepository securityContextRepo = getSecurityContextRepository( r.getAtmosphereConfig().getServletContext()); if (securityContextRepo.containsContext(r.getRequest())) { LOGGER.trace("Loading the security context from the session"); final HttpRequestResponseHolder requestResponse = new HttpRequestResponseHolder(r.getRequest(), r.getResponse()); final SecurityContext securityContext = securityContextRepo.loadContext(requestResponse); SecurityContextHolder.setContext(securityContext); } return Action.CONTINUE; }
public SecurityContextRepositoryResponseWrapper(HttpServletRequest request, HttpServletResponse response, SecurityContextRepository repository) { super(response, false); notNull(request); notNull(response); notNull(repository); this.request = request; this.repository = repository; }
@Bean public SecurityContextRepository securityContextRepository(){ return new HttpSessionSecurityContextRepository(); }
@Bean public SessionManagementFilter sessionManagementFilter(SecurityContextRepository securityContextRepository, SessionAuthenticationStrategy sessionAuthenticationStrategy){ return new SessionManagementFilter(securityContextRepository, sessionAuthenticationStrategy); }
private void addSessionManagementFilter(List<Filter> filters, SecurityContextRepository contextRepository) { SessionManagementFilter sessionManagementFilter = new SessionManagementFilter(contextRepository); filters.add(sessionManagementFilter); }
private void addSecurityContextPersistenceFilter(List<Filter> filters, SecurityContextRepository contextRepository) { SecurityContextPersistenceFilter securityContextFilter = new SecurityContextPersistenceFilter(contextRepository); filters.add(securityContextFilter); }
public void setSecurityContextRepository(SecurityContextRepository repo) { this.repo = repo; }
@Override public SecurityContextRepository getSecurityContextRepo() { return securityContextRepo; }
public void setSecurityContextRepo( SecurityContextRepository securityContextRepo) { this.securityContextRepo = securityContextRepo; }
/** * Returns the Security Context * * @returns {@link org.springframework.security.web.context.SecurityContextRepository} * Security Context */ public SecurityContextRepository getSecurityContextRepo();