Package com.nimbusds.oauth2.sdk.http

Examples of com.nimbusds.oauth2.sdk.http.HTTPRequest


  public void testParse()
    throws Exception {
   
    URI endpointURI = new URI("https://server.example.com/register/");
   
    HTTPRequest httpRequest = new HTTPRequest(HTTPRequest.Method.POST, endpointURI.toURL());
    httpRequest.setContentType(CommonContentTypes.APPLICATION_JSON);
   
    String json = "{"
      + "    \"redirect_uris\":[\"https://client.example.org/callback\","
      + "       \"https://client.example.org/callback2\"],"
      + "    \"client_name\":\"My Example Client\","
      + "    \"client_name#ja-Jpan-JP\":\"\\u30AF\\u30E9\\u30A4\\u30A2\\u30F3\\u30C8\\u540D\","
      + "    \"token_endpoint_auth_method\":\"client_secret_basic\","
      + "    \"scope\":\"read write dolphin\","
      + "    \"logo_uri\":\"https://client.example.org/logo.png\","
      + "    \"jwks_uri\":\"https://client.example.org/my_public_keys.jwks\""
      + "   }";
   
   
    httpRequest.setQuery(json);
   
    ClientRegistrationRequest request = ClientRegistrationRequest.parse(httpRequest);
   
    assertNull(request.getAccessToken());
   
View Full Code Here


    assertEquals(endpointURI, request.getEndpointURI());
    assertEquals(token, request.getAccessToken());
    assertEquals(HTTPRequest.Method.GET, request.getMethod());

    HTTPRequest httpRequest = request.toHTTPRequest();

    assertEquals(HTTPRequest.Method.GET, httpRequest.getMethod());
    assertEquals(endpointURI, httpRequest.getURL().toURI());
    assertNull(httpRequest.getQuery());
    assertEquals(token.toAuthorizationHeader(), httpRequest.getAuthorization());

    request = UserInfoRequest.parse(httpRequest);

    assertEquals(endpointURI, request.getEndpointURI());
    assertEquals(token, request.getAccessToken());
View Full Code Here

    assertEquals(url, request.getEndpointURI());
    assertEquals(token, request.getAccessToken());
    assertEquals(HTTPRequest.Method.POST, request.getMethod());

    HTTPRequest httpRequest = request.toHTTPRequest();

    assertEquals(HTTPRequest.Method.POST, httpRequest.getMethod());
    assertEquals(url, httpRequest.getURL().toURI());
    assertEquals("application/x-www-form-urlencoded; charset=UTF-8", httpRequest.getContentType().toString());
    assertEquals("access_token="+token.getValue(), httpRequest.getQuery());
    assertNull(httpRequest.getAuthorization());

    request = UserInfoRequest.parse(httpRequest);

    assertEquals(url, request.getEndpointURI());
    assertEquals(token, request.getAccessToken());
View Full Code Here

    Map<String,String> params = URLUtils.parseParameters(query);
    assertEquals("code", params.get("response_type"));
    assertEquals("123456", params.get("client_id"));
    assertEquals(2, params.size());

    HTTPRequest httpReq = req.toHTTPRequest();
    assertEquals(HTTPRequest.Method.GET, httpReq.getMethod());
    assertEquals(uri, httpReq.getURL().toURI());
    assertEquals(query, httpReq.getQuery());

    req = AuthorizationRequest.parse(uri, query);

    assertEquals(uri, req.getEndpointURI());
    assertEquals(rts, req.getResponseType());
View Full Code Here

    assertEquals(redirectURI.toString(), params.get("redirect_uri"));
    assertEquals(scope, Scope.parse(params.get("scope")));
    assertEquals(state, new State(params.get("state")));
    assertEquals(5, params.size());

    HTTPRequest httpReq = req.toHTTPRequest();
    assertEquals(HTTPRequest.Method.GET, httpReq.getMethod());
    assertEquals(query, httpReq.getQuery());

    req = AuthorizationRequest.parse(uri, query);

    assertEquals(uri, req.getEndpointURI());
    assertEquals(rts, req.getResponseType());
View Full Code Here

    } catch (MalformedURLException e) {

      throw new SerializeException(e.getMessage(), e);
    }
 
    HTTPRequest httpRequest = new HTTPRequest(httpMethod, endpointURL);
   
    switch (httpMethod) {
   
      case GET:
        httpRequest.setAuthorization(getAccessToken().toAuthorizationHeader());
        break;
       
      case POST:
        httpRequest.setContentType(CommonContentTypes.APPLICATION_URLENCODED);
        httpRequest.setQuery("access_token=" + getAccessToken().getValue());
        break;
     
      default:
        throw new SerializeException("Unexpected HTTP method: " + httpMethod);
    }
View Full Code Here

    assertEquals(metadata, request.getClientMetadata());
    assertEquals(jwt, request.getSoftwareStatement());
    assertNull(request.getAccessToken());

    HTTPRequest httpRequest = request.toHTTPRequest();

    request = ClientRegistrationRequest.parse(httpRequest);

    assertEquals("https://client.com/in", request.getClientMetadata().getRedirectionURIs().iterator().next().toString());
    assertEquals("Test App", request.getClientMetadata().getName());
View Full Code Here


  public void testParseWithMissingAuthorizationHeader()
    throws Exception {

    HTTPRequest httpRequest = new HTTPRequest(HTTPRequest.Method.DELETE, new URL("https://c2id.com/client-reg/123"));

    try {
      ClientDeleteRequest.parse(httpRequest);

      fail();
View Full Code Here

    ClientReadRequest request = new ClientReadRequest(uri, accessToken);

    assertEquals(uri, request.getEndpointURI());
    assertEquals(accessToken, request.getAccessToken());

    HTTPRequest httpRequest = request.toHTTPRequest();

    assertEquals(HTTPRequest.Method.GET, httpRequest.getMethod());
    assertEquals(uri, httpRequest.getURL().toURI());
    assertEquals(accessToken.toAuthorizationHeader(), httpRequest.getAuthorization());

    request = ClientReadRequest.parse(httpRequest);

    assertEquals(uri.toString(), request.getEndpointURI().toString());
    assertEquals(accessToken.getValue(), request.getAccessToken().getValue());
View Full Code Here


  public void testParseWithMissingAuthorizationHeader()
    throws Exception {

    HTTPRequest httpRequest = new HTTPRequest(HTTPRequest.Method.GET, new URL("https://c2id.com/client-reg/123"));

    try {
      ClientReadRequest.parse(httpRequest);

      fail();
View Full Code Here

TOP

Related Classes of com.nimbusds.oauth2.sdk.http.HTTPRequest

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.