Examples of AuthorizationRequest


Examples of org.springframework.security.oauth2.provider.AuthorizationRequest

      public boolean isApproved(AuthorizationRequest authorizationRequest, Authentication userAuthentication) {
        return true;
      }
    });
    AuthorizationRequest authorizationRequest = getAuthorizationRequest("foo", "http://anywhere.com", "mystate",
        "myscope", Collections.singleton("token"));
    ModelAndView result = endpoint.authorize(model, authorizationRequest.getRequestParameters(), sessionStatus,
        principal);
    String url = ((RedirectView) result.getView()).getUrl();
    assertTrue("Wrong view: " + result, url.startsWith("http://anywhere.com"));
    assertTrue("Wrong state: " + result, url.contains("&state=mystate"));
    assertTrue("Wrong token: " + result, url.contains("access_token="));
View Full Code Here

Examples of org.springframework.security.oauth2.provider.AuthorizationRequest

      public boolean isApproved(AuthorizationRequest authorizationRequest, Authentication userAuthentication) {
        return true;
      }
    });
    AuthorizationRequest authorizationRequest = getAuthorizationRequest("foo", "http://anywhere.com", "mystate",
        "myscope", Collections.singleton("token"));
    ModelAndView result = endpoint.authorize(model, authorizationRequest.getRequestParameters(), sessionStatus,
        principal);
    String url = ((RedirectView) result.getView()).getUrl();
    assertTrue("Wrong scope: " + result, url.contains("&scope=read"));
  }
View Full Code Here

Examples of org.springframework.security.oauth2.provider.AuthorizationRequest

    endpoint.setUserApprovalHandler(new DefaultUserApprovalHandler() {
      public boolean isApproved(AuthorizationRequest authorizationRequest, Authentication userAuthentication) {
        return true;
      }
    });
    AuthorizationRequest authorizationRequest = getAuthorizationRequest("foo", "http://anywhere.com?foo=bar",
        "mystate", "myscope", Collections.singleton("token"));
    ModelAndView result = endpoint.authorize(model, authorizationRequest.getRequestParameters(), sessionStatus,
        principal);
    String url = ((RedirectView) result.getView()).getUrl();
    assertTrue("Wrong url: " + result, url.contains("foo=bar"));
  }
View Full Code Here

Examples of org.springframework.security.oauth2.provider.AuthorizationRequest

          Authentication userAuthentication) {
        return authorizationRequest;
      }
    });
    client.setScope(Collections.singleton("read"));
    AuthorizationRequest authorizationRequest = getAuthorizationRequest("foo", "http://anywhere.com", "mystate",
        null, Collections.singleton("token"));
    ModelAndView result = endpoint.authorize(model, authorizationRequest.getRequestParameters(), sessionStatus,
        principal);
    String url = ((RedirectView) result.getView()).getUrl();
    assertTrue("Wrong scope: " + result, url.contains("&scope=read%20write"));
  }
View Full Code Here

Examples of org.springframework.security.oauth2.provider.AuthorizationRequest

          Authentication userAuthentication) {
        return authorizationRequest;
      }
    });
    client.setScope(Collections.singleton("smallscope"));
    AuthorizationRequest authorizationRequest = getAuthorizationRequest("foo", "http://anywhere.com", "mystate",
        "bigscope", Collections.singleton("token"));
    ModelAndView result = endpoint.authorize(model, authorizationRequest.getRequestParameters(), sessionStatus,
        principal);
    String url = ((RedirectView) result.getView()).getUrl();
    assertTrue("Wrong view: " + result, url.startsWith("http://anywhere.com"));
  }
View Full Code Here

Examples of org.springframework.security.oauth2.provider.AuthorizationRequest

    endpoint.setTokenGranter(new TokenGranter() {
      public OAuth2AccessToken grant(String grantType, TokenRequest tokenRequest) {
        return null;
      }
    });
    AuthorizationRequest authorizationRequest = getAuthorizationRequest("foo", "http://anywhere.com", "mystate",
        "myscope", Collections.singleton("token"));
    ModelAndView result = endpoint.authorize(model, authorizationRequest.getRequestParameters(), sessionStatus,
        principal);
    assertEquals("forward:/oauth/confirm_access", result.getViewName());
  }
View Full Code Here

Examples of org.springframework.security.oauth2.provider.AuthorizationRequest

    endpoint.setTokenGranter(new TokenGranter() {
      public OAuth2AccessToken grant(String grantType, TokenRequest tokenRequest) {
        return null;
      }
    });
    AuthorizationRequest authorizationRequest = getAuthorizationRequest("foo", "http://anywhere.com", "mystate",
        "myscope", Collections.singleton("token"));
    ModelAndView result = endpoint.authorize(model, authorizationRequest.getRequestParameters(), sessionStatus,
        principal);

    String url = ((RedirectView) result.getView()).getUrl();
    assertTrue("Wrong view: " + result, url.startsWith("http://anywhere.com"));
    assertTrue("No error: " + result, url.contains("#error="));
View Full Code Here

Examples of org.springframework.security.oauth2.provider.AuthorizationRequest

  }

  @Test
  public void testApproveOrDeny() throws Exception {
    AuthorizationRequest request = getAuthorizationRequest("foo", "http://anywhere.com", null, null,
        Collections.singleton("code"));
    request.setApproved(true);
    Map<String, String> approvalParameters = new HashMap<String, String>();
    approvalParameters.put("user_oauth_approval", "true");
    model.put("authorizationRequest", request);
    View result = endpoint.approveOrDeny(approvalParameters, model, sessionStatus, principal);
    assertTrue("Wrong view: " + result, ((RedirectView) result).getUrl().startsWith("http://anywhere.com"));
View Full Code Here

Examples of org.springframework.security.oauth2.provider.AuthorizationRequest

  public void testRedirectUriOptionalForAuthorization() throws Exception {
    ModelAndView result = endpoint.authorize(model,
        getAuthorizationRequest("foo", null, null, "read", Collections.singleton("code"))
            .getRequestParameters(), sessionStatus, principal);
    // RedirectUri parameter should be null (SECOAUTH-333), however the resolvedRedirectUri not
    AuthorizationRequest authorizationRequest = (AuthorizationRequest) result.getModelMap().get(
        "authorizationRequest");
    assertNull(authorizationRequest.getRequestParameters().get(OAuth2Utils.REDIRECT_URI));
    assertEquals("http://anywhere.com", authorizationRequest.getRedirectUri());
  }
View Full Code Here

Examples of org.springframework.security.oauth2.provider.AuthorizationRequest

   * Ensure that if the approval endpoint is called without a resolved redirect URI, the request fails.
   * @throws Exception
   */
  @Test(expected = InvalidRequestException.class)
  public void testApproveOrDenyWithOAuth2RequestWithoutRedirectUri() throws Exception {
    AuthorizationRequest request = getAuthorizationRequest("foo", null, null, null, Collections.singleton("code"));
    request.setApproved(true);
    Map<String, String> approvalParameters = new HashMap<String, String>();
    approvalParameters.put("user_oauth_approval", "true");
    model.put("authorizationRequest", request);
    endpoint.approveOrDeny(approvalParameters, model, sessionStatus, principal);

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.