Package org.springframework.security.oauth.provider.filter

Examples of org.springframework.security.oauth.provider.filter.UserAuthorizationSuccessfulAuthenticationHandler


   * test determineTargetUrl
   */
  @Test
  public void testAuthenticationSuccess() throws Exception {

    UserAuthorizationSuccessfulAuthenticationHandler handler = new UserAuthorizationSuccessfulAuthenticationHandler();
    HttpServletRequest request = mock(HttpServletRequest.class);
    HttpServletResponse response = mock(HttpServletResponse.class);
    RedirectStrategy redirectStrategy = mock(RedirectStrategy.class);
    handler.setRedirectStrategy(redirectStrategy);

    when(request.getAttribute(UserAuthorizationProcessingFilter.CALLBACK_ATTRIBUTE)).thenReturn(
        "http://my.host.com/my/context");
    when(request.getAttribute(UserAuthorizationProcessingFilter.VERIFIER_ATTRIBUTE)).thenReturn("myver");
    when(request.getParameter("requestToken")).thenReturn("mytok");


    handler.onAuthenticationSuccess(request, response, null);

    verify(redirectStrategy).sendRedirect(request, response,
        "http://my.host.com/my/context?oauth_token=mytok&oauth_verifier=myver");

    handler = new UserAuthorizationSuccessfulAuthenticationHandler();
    handler.setRedirectStrategy(redirectStrategy);

    when(request.getAttribute(UserAuthorizationProcessingFilter.CALLBACK_ATTRIBUTE)).thenReturn(
        "http://my.hosting.com/my/context?with=some&query=parameter");
    when(request.getAttribute(UserAuthorizationProcessingFilter.VERIFIER_ATTRIBUTE)).thenReturn("myvera");
    when(request.getParameter("requestToken")).thenReturn("mytoka");

    handler.onAuthenticationSuccess(request, response, null);

    verify(redirectStrategy).sendRedirect(request, response,
        "http://my.hosting.com/my/context?with=some&query=parameter&oauth_token=mytoka&oauth_verifier=myvera");
  }
View Full Code Here

TOP

Related Classes of org.springframework.security.oauth.provider.filter.UserAuthorizationSuccessfulAuthenticationHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.