SAMLEntryPoint extends GenericFilterBean implements AuthenticationEntryPoint { public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) throws IOException, ServletException { try { SAMLMessageContext context = contextProvider.getLocalAndPeerEntity(request, response); if (isECP(context)) { initializeECP(context, e); } else if (isDiscovery(context)) { initializeDiscovery(context); } else { initializeSSO(context, e); } } catch (SAMLException e1) { log.debug("Error initializing entry point", e1); throw new ServletException(e1); } catch (MetadataProviderException e1) { log.debug("Error initializing entry point", e1); throw new ServletException(e1); } catch (MessageEncodingException e1) { log.debug("Error initializing entry point", e1); throw new ServletException(e1); } }  void doFilter(ServletRequest request, ServletResponse response, FilterChain chain); void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e); void setDefaultProfileOptions(WebSSOProfileOptions defaultOptions); @Autowired @Qualifier("webSSOprofile") void setWebSSOprofile(WebSSOProfile webSSOprofile); @Autowired(required = false) @Qualifier("ecpprofile") void setWebSSOprofileECP(WebSSOProfile webSSOprofileECP); @Autowired(required = false) @Qualifier("hokWebSSOProfile") void setWebSSOprofileHoK(WebSSOProfile webSSOprofileHoK); @Autowired void setSamlLogger(SAMLLogger samlLogger); @Autowired(required = false) void setSamlDiscovery(SAMLDiscovery samlDiscovery); @Autowired void setContextProvider(SAMLContextProvider contextProvider); @Autowired void setMetadata(MetadataManager metadata); String getFilterProcessesUrl(); void setFilterProcessesUrl(String filterProcessesUrl); @Override void afterPropertiesSet(); static final String FILTER_URL; static final String IDP_PARAMETER; static final String DISCOVERY_RESPONSE_PARAMETER; }
@Test(expected = ServletException.class) public void testInvalidIDP() throws Exception { expect(request.getSession(true)).andReturn(session); expect(request.getParameter(SAMLEntryPoint.DISCOVERY_RESPONSE_PARAMETER)).andReturn("false"); SAMLTestHelper.setLocalContextParameters(request, "/samlApp", null); SAMLTestHelper.setPeerContextParameters(request, "testIDP", null); expect(request.getAttribute(org.springframework.security.saml.SAMLConstants.LOCAL_CONTEXT_PATH)).andReturn("/samlApp"); expect(request.getHeader("Accept")).andReturn( "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); expect(request.getHeader(org.springframework.security.saml.SAMLConstants.PAOS_HTTP_HEADER)).andReturn(null); replayMock(); entryPoint.commence(request, response, null); verifyMock(); }
@Test public void testCorrectIDP() throws Exception { expect(request.getSession(true)).andReturn(session); SAMLTestHelper.setLocalContextParameters(request, "/samlApp", null); SAMLTestHelper.setPeerContextParameters(request, "http: expect(request.getHeader("Accept")).andReturn("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); expect(request.getHeader(org.springframework.security.saml.SAMLConstants.PAOS_HTTP_HEADER)).andReturn(null); ssoProfile.sendAuthenticationRequest((SAMLMessageContext) notNull(), (WebSSOProfileOptions) notNull()); replayMock(); entryPoint.commence(request, response, null); verifyMock(); }
@Test public void testIDPSelection_defaultURL() throws Exception { expect(request.getSession(true)).andReturn(session); expect(request.getHeader("Accept")).andReturn("text/html"); expect(request.getHeader(org.springframework.security.saml.SAMLConstants.PAOS_HTTP_HEADER)).andReturn(null); expect(request.getParameter(SAMLEntryPoint.DISCOVERY_RESPONSE_PARAMETER)).andReturn("false"); SAMLTestHelper.setLocalContextParameters(request, "/samlApp", null); SAMLTestHelper.setPeerContextParameters(request, null, null); expect(request.getAttribute(org.springframework.security.saml.SAMLConstants.LOCAL_CONTEXT_PATH)).andReturn("/samlApp"); response.sendRedirect("/samlApp/saml/discovery?returnIDParam=idp&entityID=http: replayMock(); entryPoint.commence(request, response, null); verifyMock(); }