Package net.minidev.json

Examples of net.minidev.json.JSONObject


   *                            serialised to a JSON object.
   */
  public JSONObject toJSONObject()
    throws SerializeException {
 
    JSONObject o = accessToken.toJSONObject();

    if (refreshToken != null)
      o.putAll(refreshToken.toJSONObject());

    if (customParams != null)
      o.putAll(customParams);
   
    return o;
  }
View Full Code Here


  public static AccessTokenResponse parse(final HTTPResponse httpResponse)
    throws ParseException {
   
    httpResponse.ensureStatusCode(HTTPResponse.SC_OK);
   
    JSONObject jsonObject = httpResponse.getContentAsJSONObject();
   
    return parse(jsonObject);
  }
View Full Code Here

        }

        @Override
        public JSONObject toJSONObject() {

          return new JSONObject();
        }

        @Override
        public boolean equals(final Object other) {
View Full Code Here

   *
   * @return The JSON object for this token error response.
   */
  public JSONObject toJSONObject() {
 
    JSONObject o = new JSONObject();

    // No error?
    if (error == null)
      return o;

    o.put("error", error.getCode());

    if (error.getDescription() != null)
      o.put("error_description", error.getDescription());
   
    if (error.getURI() != null)
      o.put("error_uri", error.getURI().toString());
   
    return o;
  }
View Full Code Here

      // ok
    }


    // Simulate JSON object with none token endpoint JWT algs
    JSONObject jsonObject = meta.toJSONObject();

    List<String> stringList = new ArrayList<>();
    stringList.add("none");

    jsonObject.put("token_endpoint_auth_signing_alg_values_supported", stringList);


    try {
      OIDCProviderMetadata.parse(jsonObject.toJSONString());

      fail("Failed to raise ParseException");

    } catch (ParseException e) {
      // ok
View Full Code Here

    httpResponse.ensureStatusCodeNotOK();

    if (StringUtils.isNotEmpty(httpResponse.getContent()) &&
        CommonContentTypes.APPLICATION_JSON.match(httpResponse.getContentType())) {

      JSONObject jsonObject = httpResponse.getContentAsJSONObject();

      return parse(jsonObject);
    }

    return new TokenErrorResponse();
View Full Code Here

    logoURIEntries = new HashMap<>();
    uriEntries = new HashMap<>();
    policyURIEntries = new HashMap<>();
    policyURIEntries = new HashMap<>();
    tosURIEntries = new HashMap<>();
    customFields = new JSONObject();
  }
View Full Code Here

   *
   * @return The JSON object.
   */
  public JSONObject toJSONObject(final boolean includeCustomFields) {

    JSONObject o;

    if (includeCustomFields)
      o = new JSONObject(customFields);
    else
      o = new JSONObject();


    if (redirectURIs != null) {

      JSONArray uriList = new JSONArray();

      for (URI uri: redirectURIs)
        uriList.add(uri.toString());

      o.put("redirect_uris", uriList);
    }


    if (scope != null)
      o.put("scope", scope.toString());


    if (responseTypes != null) {

      JSONArray rtList = new JSONArray();

      for (ResponseType rt: responseTypes)
        rtList.add(rt.toString());

      o.put("response_types", rtList);
    }


    if (grantTypes != null) {

      JSONArray grantList = new JSONArray();

      for (GrantType grant: grantTypes)
        grantList.add(grant.toString());

      o.put("grant_types", grantList);
    }


    if (contacts != null) {

      JSONArray contactList = new JSONArray();

      for (InternetAddress email: contacts)
        contactList.add(email.toString());

      o.put("contacts", contactList);
    }


    if (! nameEntries.isEmpty()) {

      for (Map.Entry<LangTag,String> entry: nameEntries.entrySet()) {

        LangTag langTag = entry.getKey();
        String name = entry.getValue();

        if (name == null)
          continue;

        if (langTag == null)
          o.put("client_name", entry.getValue());
        else
          o.put("client_name#" + langTag, entry.getValue());
      }
    }


    if (! logoURIEntries.isEmpty()) {

      for (Map.Entry<LangTag,URI> entry: logoURIEntries.entrySet()) {

        LangTag langTag = entry.getKey();
        URI uri = entry.getValue();

        if (uri == null)
          continue;

        if (langTag == null)
          o.put("logo_uri", entry.getValue().toString());
        else
          o.put("logo_uri#" + langTag, entry.getValue().toString());
      }
    }


    if (! uriEntries.isEmpty()) {

      for (Map.Entry<LangTag,URI> entry: uriEntries.entrySet()) {

        LangTag langTag = entry.getKey();
        URI uri = entry.getValue();

        if (uri == null)
          continue;

        if (langTag == null)
          o.put("client_uri", entry.getValue().toString());
        else
          o.put("client_uri#" + langTag, entry.getValue().toString());
      }
    }


    if (! policyURIEntries.isEmpty()) {

      for (Map.Entry<LangTag,URI> entry: policyURIEntries.entrySet()) {

        LangTag langTag = entry.getKey();
        URI uri = entry.getValue();

        if (uri == null)
          continue;

        if (langTag == null)
          o.put("policy_uri", entry.getValue().toString());
        else
          o.put("policy_uri#" + langTag, entry.getValue().toString());
      }
    }


    if (! tosURIEntries.isEmpty()) {

      for (Map.Entry<LangTag,URI> entry: tosURIEntries.entrySet()) {

        LangTag langTag = entry.getKey();
        URI uri = entry.getValue();

        if (uri == null)
          continue;

        if (langTag == null)
          o.put("tos_uri", entry.getValue().toString());
        else
          o.put("tos_uri#" + langTag, entry.getValue().toString());
      }
    }


    if (authMethod != null)
      o.put("token_endpoint_auth_method", authMethod.toString());


    if (jwkSetURI != null)
      o.put("jwks_uri", jwkSetURI.toString());


    if (jwkSet != null)
      o.put("jwks", jwkSet.toJSONObject(true)); // prevent private keys from leaking


    if (softwareID != null)
      o.put("software_id", softwareID.getValue());

    if (softwareVersion != null)
      o.put("software_version", softwareVersion.getValue());

    return o;
  }
View Full Code Here


  @Override
  public JSONObject toJSONObject() {

    JSONObject o = new JSONObject();

    o.put("access_token", getValue());
    o.put("token_type", type.toString());
   
    if (getLifetime() > 0)
      o.put("expires_in", lifetime);

    if (getScope() != null)
      o.put("scope", scope.toString());
   
    return o;
  }
View Full Code Here

    Map<String,String> params = request.getQueryParameters();
    assertEquals("123", params.get("x"));
    assertEquals("456", params.get("y"));

    request.setQuery("{\"apples\":\"123\"}");
    JSONObject jsonObject = request.getQueryAsJSONObject();
    assertEquals("123", (String)jsonObject.get("apples"));

    assertEquals(0, request.getConnectTimeout());
    request.setConnectTimeout(250);
    assertEquals(250, request.getConnectTimeout());
View Full Code Here

TOP

Related Classes of net.minidev.json.JSONObject

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.