@Test public void testCorrectPass() throws Exception { Authentication token = new UsernamePasswordAuthenticationToken("user", "pass"); AuthenticationManager manager = createMock(AuthenticationManager.class); processingFiler.setAuthenticationManager(manager); expect(request.getContextPath()).andReturn("/saml"); expect(processor.retrieveMessage((SAMLMessageContext) notNull())).andReturn(new SAMLMessageContext()); expect(manager.authenticate((Authentication) notNull())).andReturn(token); expect(request.getSession(true)).andReturn(session); expect(session.getAttribute("_springSamlStorageKey")).andReturn(new Hashtable()); replay(manager); replayMock(); Authentication authentication = processingFiler.attemptAuthentication(request, null); assertEquals(token, authentication); verifyMock(); verify(manager); }
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException { try { SAMLMessageContext context = contextProvider.getLocalEntity(request, response); logger.debug("Attempting SAML2 authentication"); processor.retrieveMessage(context); HttpSessionStorage storage = new HttpSessionStorage(request); SAMLAuthenticationToken token = new SAMLAuthenticationToken(context, storage); return getAuthenticationManager().authenticate(token); } catch (SAMLException e) { throw new SAMLRuntimeException("Incoming SAML message is invalid", e); } catch (MetadataProviderException e) { throw new SAMLRuntimeException("Error determining metadata contracts", e); } catch (MessageDecodingException e) { throw new SAMLRuntimeException("Error decoding incoming SAML message", e); } catch (org.opensaml.xml.security.SecurityException e) { throw new SAMLRuntimeException("Incoming SAML message is invalid", e); } }
SAMLProcessingFilter extends AbstractAuthenticationProcessingFilter { public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException { try { SAMLMessageContext context = contextProvider.getLocalEntity(request, response); logger.debug("Attempting SAML2 authentication"); processor.retrieveMessage(context); HttpSessionStorage storage = new HttpSessionStorage(request); SAMLAuthenticationToken token = new SAMLAuthenticationToken(context, storage); return getAuthenticationManager().authenticate(token); } catch (SAMLException e) { throw new SAMLRuntimeException("Incoming SAML message is invalid", e); } catch (MetadataProviderException e) { throw new SAMLRuntimeException("Error determining metadata contracts", e); } catch (MessageDecodingException e) { throw new SAMLRuntimeException("Error decoding incoming SAML message", e); } catch (org.opensaml.xml.security.SecurityException e) { throw new SAMLRuntimeException("Incoming SAML message is invalid", e); } } }
SAMLProcessingFilter extends AbstractAuthenticationProcessingFilter { public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException { try { SAMLMessageContext context = contextProvider.getLocalEntity(request, response); logger.debug("Attempting SAML2 authentication"); processor.retrieveMessage(context); HttpSessionStorage storage = new HttpSessionStorage(request); SAMLAuthenticationToken token = new SAMLAuthenticationToken(context, storage); return getAuthenticationManager().authenticate(token); } catch (SAMLException e) { throw new SAMLRuntimeException("Incoming SAML message is invalid", e); } catch (MetadataProviderException e) { throw new SAMLRuntimeException("Error determining metadata contracts", e); } catch (MessageDecodingException e) { throw new SAMLRuntimeException("Error decoding incoming SAML message", e); } catch (org.opensaml.xml.security.SecurityException e) { throw new SAMLRuntimeException("Incoming SAML message is invalid", e); } } SAMLProcessingFilter(); }
SAMLProcessingFilter extends AbstractAuthenticationProcessingFilter { public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException { try { SAMLMessageContext context = contextProvider.getLocalEntity(request, response); logger.debug("Attempting SAML2 authentication"); processor.retrieveMessage(context); HttpSessionStorage storage = new HttpSessionStorage(request); SAMLAuthenticationToken token = new SAMLAuthenticationToken(context, storage); return getAuthenticationManager().authenticate(token); } catch (SAMLException e) { throw new SAMLRuntimeException("Incoming SAML message is invalid", e); } catch (MetadataProviderException e) { throw new SAMLRuntimeException("Error determining metadata contracts", e); } catch (MessageDecodingException e) { throw new SAMLRuntimeException("Error decoding incoming SAML message", e); } catch (org.opensaml.xml.security.SecurityException e) { throw new SAMLRuntimeException("Incoming SAML message is invalid", e); } } SAMLProcessingFilter(); Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response); @Deprecated void setDefaultTargetUrl(String url); @Autowired void setSAMLProcessor(SAMLProcessor processor); @Autowired void setContextProvider(SAMLContextProvider contextProvider); @Override void afterPropertiesSet(); }
SAMLProcessingFilter extends AbstractAuthenticationProcessingFilter { public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException { try { SAMLMessageContext context = contextProvider.getLocalEntity(request, response); logger.debug("Attempting SAML2 authentication"); processor.retrieveMessage(context); HttpSessionStorage storage = new HttpSessionStorage(request); SAMLAuthenticationToken token = new SAMLAuthenticationToken(context, storage); return getAuthenticationManager().authenticate(token); } catch (SAMLException e) { throw new SAMLRuntimeException("Incoming SAML message is invalid", e); } catch (MetadataProviderException e) { throw new SAMLRuntimeException("Error determining metadata contracts", e); } catch (MessageDecodingException e) { throw new SAMLRuntimeException("Error decoding incoming SAML message", e); } catch (org.opensaml.xml.security.SecurityException e) { throw new SAMLRuntimeException("Incoming SAML message is invalid", e); } } SAMLProcessingFilter(); Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response); @Deprecated void setDefaultTargetUrl(String url); @Autowired void setSAMLProcessor(SAMLProcessor processor); @Autowired void setContextProvider(SAMLContextProvider contextProvider); @Override void afterPropertiesSet();  }