@Test public void testAlreadyAuthenticatedDoesNotRedirect() throws ServletException, IOException { initMocksForAuthenticated(); when(httpServletRequest.getSession(true)).thenReturn(httpSession); testee.doFilterInternal(httpServletRequest, httpServletResponse, filterChain); verify(httpServletResponse, times(0)).sendRedirect(anyString()); }
@Override protected void doFilterInternal(HttpServletRequest req, HttpServletResponse resp, FilterChain filterChain) throws ServletException, IOException { HttpSession session = req.getSession(true); if (session != null && hasSessionWithSpringContext(session)) { Authentication authentication = extractAuthentication(session); if (isAuthenticatedInWebcert(authentication)) { filterChain.doFilter(req, resp); return; } } if (session != null) { SavedRequest savedRequest = savedRequestFactory.buildSavedRequest(req); session.setAttribute(SPRING_SECURITY_SAVED_REQUEST_KEY, savedRequest); redisSavedRequestCache.saveRequest(req, resp); } String requestURI = req.getRequestURI(); if (isAuthenticateWithSiths(requestURI)) { resp.sendRedirect("/saml/login/alias/" + AuthConstants.ALIAS_SITHS + "?idp=" + sithsIdp); } if (isAuthenticateWithEleg(requestURI)) { resp.sendRedirect("/saml/login/alias/" + AuthConstants.ALIAS_ELEG + "?idp=" + elegIdp); } }
IdpSelectionFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest req, HttpServletResponse resp, FilterChain filterChain) throws ServletException, IOException { HttpSession session = req.getSession(true); if (session != null && hasSessionWithSpringContext(session)) { Authentication authentication = extractAuthentication(session); if (isAuthenticatedInWebcert(authentication)) { filterChain.doFilter(req, resp); return; } } if (session != null) { SavedRequest savedRequest = savedRequestFactory.buildSavedRequest(req); session.setAttribute(SPRING_SECURITY_SAVED_REQUEST_KEY, savedRequest); redisSavedRequestCache.saveRequest(req, resp); } String requestURI = req.getRequestURI(); if (isAuthenticateWithSiths(requestURI)) { resp.sendRedirect("/saml/login/alias/" + AuthConstants.ALIAS_SITHS + "?idp=" + sithsIdp); } if (isAuthenticateWithEleg(requestURI)) { resp.sendRedirect("/saml/login/alias/" + AuthConstants.ALIAS_ELEG + "?idp=" + elegIdp); } } }
IdpSelectionFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest req, HttpServletResponse resp, FilterChain filterChain) throws ServletException, IOException { HttpSession session = req.getSession(true); if (session != null && hasSessionWithSpringContext(session)) { Authentication authentication = extractAuthentication(session); if (isAuthenticatedInWebcert(authentication)) { filterChain.doFilter(req, resp); return; } } if (session != null) { SavedRequest savedRequest = savedRequestFactory.buildSavedRequest(req); session.setAttribute(SPRING_SECURITY_SAVED_REQUEST_KEY, savedRequest); redisSavedRequestCache.saveRequest(req, resp); } String requestURI = req.getRequestURI(); if (isAuthenticateWithSiths(requestURI)) { resp.sendRedirect("/saml/login/alias/" + AuthConstants.ALIAS_SITHS + "?idp=" + sithsIdp); } if (isAuthenticateWithEleg(requestURI)) { resp.sendRedirect("/saml/login/alias/" + AuthConstants.ALIAS_ELEG + "?idp=" + elegIdp); } }  }
IdpSelectionFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest req, HttpServletResponse resp, FilterChain filterChain) throws ServletException, IOException { HttpSession session = req.getSession(true); if (session != null && hasSessionWithSpringContext(session)) { Authentication authentication = extractAuthentication(session); if (isAuthenticatedInWebcert(authentication)) { filterChain.doFilter(req, resp); return; } } if (session != null) { SavedRequest savedRequest = savedRequestFactory.buildSavedRequest(req); session.setAttribute(SPRING_SECURITY_SAVED_REQUEST_KEY, savedRequest); redisSavedRequestCache.saveRequest(req, resp); } String requestURI = req.getRequestURI(); if (isAuthenticateWithSiths(requestURI)) { resp.sendRedirect("/saml/login/alias/" + AuthConstants.ALIAS_SITHS + "?idp=" + sithsIdp); } if (isAuthenticateWithEleg(requestURI)) { resp.sendRedirect("/saml/login/alias/" + AuthConstants.ALIAS_ELEG + "?idp=" + elegIdp); } }  void setSavedRequestFactory(SavedRequestFactory savedRequestFactory); }
IdpSelectionFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest req, HttpServletResponse resp, FilterChain filterChain) throws ServletException, IOException { HttpSession session = req.getSession(true); if (session != null && hasSessionWithSpringContext(session)) { Authentication authentication = extractAuthentication(session); if (isAuthenticatedInWebcert(authentication)) { filterChain.doFilter(req, resp); return; } } if (session != null) { SavedRequest savedRequest = savedRequestFactory.buildSavedRequest(req); session.setAttribute(SPRING_SECURITY_SAVED_REQUEST_KEY, savedRequest); redisSavedRequestCache.saveRequest(req, resp); } String requestURI = req.getRequestURI(); if (isAuthenticateWithSiths(requestURI)) { resp.sendRedirect("/saml/login/alias/" + AuthConstants.ALIAS_SITHS + "?idp=" + sithsIdp); } if (isAuthenticateWithEleg(requestURI)) { resp.sendRedirect("/saml/login/alias/" + AuthConstants.ALIAS_ELEG + "?idp=" + elegIdp); } }  void setSavedRequestFactory(SavedRequestFactory savedRequestFactory);  }