Package com.nimbusds.oauth2.sdk.http

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



  public void testParseFromHTTPRequestInvalid()
    throws Exception {

    HTTPRequest httpRequest = new HTTPRequest(HTTPRequest.Method.GET, new URL("http://c2id.com/reg/123"));
    httpRequest.setAuthorization("Bearer");

    try {
      BearerAccessToken.parse(httpRequest);
      fail();
View Full Code Here


    } catch (MalformedURLException e) {

      throw new SerializeException(e.getMessage(), e);
    }
 
    HTTPRequest httpRequest = new HTTPRequest(HTTPRequest.Method.GET, endpointURL);
    httpRequest.setAuthorization(getAccessToken().toAuthorizationHeader());
    return httpRequest;
  }
View Full Code Here

    } catch (MalformedURLException e) {

      throw new SerializeException(e.getMessage(), e);
    }

    HTTPRequest httpRequest = new HTTPRequest(HTTPRequest.Method.PUT, endpointURL);

    httpRequest.setAuthorization(getAccessToken().toAuthorizationHeader());

    httpRequest.setContentType(CommonContentTypes.APPLICATION_JSON);
   
    JSONObject jsonObject = metadata.toJSONObject();
   
    jsonObject.put("client_id", id.getValue());
   
    if (secret != null)
      jsonObject.put("client_secret", secret.getValue());

    httpRequest.setQuery(jsonObject.toString());

    return httpRequest;
  }
View Full Code Here

   
    assertEquals(ApplicationType.NATIVE, metadata.getApplicationType());
   
    assertEquals(new URI("https://client.example.org/my_public_keys.jwks"), metadata.getJWKSetURI());
   
    HTTPRequest httpRequest = request.toHTTPRequest();
   
    assertEquals(HTTPRequest.Method.POST, httpRequest.getMethod());
    assertEquals(CommonContentTypes.APPLICATION_JSON, httpRequest.getContentType());
   
    System.out.println(httpRequest.getQuery());
   
    request = OIDCClientRegistrationRequest.parse(httpRequest);
   
    assertEquals(uri, request.getEndpointURI());
   
View Full Code Here

      + "   \"request_uris\":[\"https://client.example.org/rf.txt#qpXaRLh_n93TTR9F252ValdatUQvQiJi5BDub2BeznA\"]"
      + "  }";
   
    System.out.println(json);
   
    HTTPRequest httpRequest = new HTTPRequest(HTTPRequest.Method.POST, uri.toURL());
    httpRequest.setAuthorization("Bearer eyJhbGciOiJSUzI1NiJ9.eyJ");
    httpRequest.setContentType(CommonContentTypes.APPLICATION_JSON);
    httpRequest.setQuery(json);
   
    OIDCClientRegistrationRequest req = OIDCClientRegistrationRequest.parse(httpRequest);
   
    assertEquals(uri, req.getEndpointURI());
   
View Full Code Here

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

    HTTPRequest httpRequest = request.toHTTPRequest();

    request = OIDCClientRegistrationRequest.parse(httpRequest);

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

    assertEquals(metadata, request.getOIDCClientMetadata());
    assertEquals(metadata, request.getClientMetadata());
    assertEquals(secret, request.getClientSecret());


    HTTPRequest httpRequest = request.toHTTPRequest();

    request = OIDCClientUpdateRequest.parse(httpRequest);

    assertEquals(uri.toString(), request.getEndpointURI().toString());
    assertEquals(clientID.getValue(), request.getClientID().getValue());
View Full Code Here

  public void testParse()
    throws Exception {
   
    URI regURI = new URI("https://server.example.com/register/s6BhdRkqt3");
   
    HTTPRequest httpRequest = new HTTPRequest(HTTPRequest.Method.PUT, regURI.toURL());
    httpRequest.setAuthorization("Bearer reg-23410913-abewfq.123483");
    httpRequest.setContentType(CommonContentTypes.APPLICATION_JSON);

    String json = "{\"client_id\":\"s6BhdRkqt3\","
      + "    \"client_secret\": \"cf136dc3c1fc93f31185e5885805d\","
      + "    \"redirect_uris\":[\"https://client.example.org/callback\",\"https://client.example.org/alt\"],"
      + "    \"scope\": \"read write dolphin\","
      + "    \"grant_types\": [\"authorization_code\", \"refresh_token\"],"
      + "    \"token_endpoint_auth_method\": \"client_secret_basic\","
      + "    \"jwks_uri\": \"https://client.example.org/my_public_keys.jwks\","
      + "    \"client_name\":\"My New Example\","
      + "    \"client_name#fr\":\"Mon Nouvel Exemple\","
      + "    \"logo_uri\":\"https://client.example.org/newlogo.png\","
      + "    \"logo_uri#fr\":\"https://client.example.org/fr/newlogo.png\""
      + "   }";

    httpRequest.setQuery(json);
   
    ClientUpdateRequest request = ClientUpdateRequest.parse(httpRequest);
   
    assertEquals(regURI, request.getEndpointURI());
   
View Full Code Here


  public void testParseWithMissingAuthorizationHeader()
    throws Exception {

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

    httpRequest.setContentType(CommonContentTypes.APPLICATION_JSON);

    String json = "{\"client_id\":\"123\","
      + "    \"client_secret\": \"cf136dc3c1fc93f31185e5885805d\","
      + "    \"redirect_uris\":[\"https://client.example.org/callback\",\"https://client.example.org/alt\"],"
      + "    \"scope\": \"read write dolphin\","
      + "    \"grant_types\": [\"authorization_code\", \"refresh_token\"],"
      + "    \"token_endpoint_auth_method\": \"client_secret_basic\","
      + "    \"jwks_uri\": \"https://client.example.org/my_public_keys.jwks\","
      + "    \"client_name\":\"My New Example\","
      + "    \"client_name#fr\":\"Mon Nouvel Exemple\","
      + "    \"logo_uri\":\"https://client.example.org/newlogo.png\","
      + "    \"logo_uri#fr\":\"https://client.example.org/fr/newlogo.png\""
      + "   }";

    httpRequest.setQuery(json);

    try {
      ClientUpdateRequest.parse(httpRequest);

      fail();
View Full Code Here

    BearerAccessToken accessToken = new BearerAccessToken();

    ClientRegistrationRequest request = new ClientRegistrationRequest(uri, metadata, accessToken);

    HTTPRequest httpRequest = request.toHTTPRequest();

    assertEquals(uri.toString(), httpRequest.getURL().toString());
    assertTrue(httpRequest.getContentType().toString().startsWith("application/json"));

    JSONObject jsonObject = httpRequest.getQueryAsJSONObject();

    System.out.println(jsonObject);

    List<String> stringList = (List<String>)jsonObject.get("redirect_uris");
    assertEquals(metadata.getRedirectionURIs().iterator().next().toString(), stringList.get(0));
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.