Package net.minidev.json

Examples of net.minidev.json.JSONObject


import org.hibernate.criterion.Restrictions;

public class PollUpdates implements JsonAction {
    @Override
    public Map execute(IDataWrapper data) {
        JSONObject result = new JSONObject();

        result.put("count", 0);

        String lastId = data.getRequestAttribute("id");

        if (lastId != null && !lastId.isEmpty()) {
            final DataHelperRike<ActivityLog> helper = new DataHelperRike<ActivityLog>(ActivityLog.class);
            List<ActivityLog> list = helper.list(helper.filter().add(Restrictions.gt("id", Long.valueOf(lastId, 10))));

            result.put("count", list.size());
        }

        return result;
    }
View Full Code Here


                Map ret = action.execute(new PortletDataWrapper(request, response));
                JSONValue.writeJSONString(ret, response.getWriter());
            }
        } catch (JsonException ex) {
            JSONObject ret = new JSONObject();
            ret.put("error", ex.getMessage());
            ret.writeJSONString(response.getWriter());
        } catch (Throwable t) {
            logger.log(Level.SEVERE, "action " + actionName + " failed ", t);
        }

        Performance.timing("arago.portlet.dispatch.json", System.currentTimeMillis() - then);
View Full Code Here

   */
  @Override
  public List<Map<String, VariableBinding>> parse(InputStream in)
      throws IOException {

    final JSONObject result = (JSONObject) JSONValue.parse(in);
    final LinkedList<Map<String, VariableBinding>> resultList = new LinkedList<Map<String, VariableBinding>>();
    handleHead((JSONObject) result.get(KEY_HEAD));
    handleResults((JSONObject) result.get(KEY_RESULTS), resultList);
    return resultList;
  }
View Full Code Here

  protected void handleBinding(JSONObject binding,
      LinkedList<Map<String, VariableBinding>> resultList) {
    _log.debug("Handling binding {}", binding);

    for (Entry<String, Object> bindingEntry : binding.entrySet()) {
      final JSONObject bindingValue = (JSONObject) bindingEntry
          .getValue();
      final String variableName = bindingEntry.getKey();
      final String type = (String) bindingValue.get(KEY_TYPE);
      final String datatype = (String) bindingValue.get(KEY_DATATYPE);
      final Object value = (String) bindingValue.get(KEY_VALUE);
      final Map<String, VariableBinding> result = new HashMap<String, VariableBinding>();
      Object[] parameters = { variableName, value, datatype, result };
      resultList.add(result);

      try {
View Full Code Here

  }


  public void testToClaimsRequestJSON() {

    JSONObject o = OIDCScopeValue.OPENID.toClaimsRequestJSONObject();
    assertTrue(o.containsKey("sub"));
    assertTrue((Boolean)((JSONObject)o.get("sub")).get("essential"));
    assertEquals(1, o.size());

    o = OIDCScopeValue.PROFILE.toClaimsRequestJSONObject();
    assertTrue(o.containsKey("name"));
    assertNull(o.get("name"));
    assertTrue(o.containsKey("family_name"));
    assertNull(o.get("family_name"));
    assertTrue(o.containsKey("given_name"));
    assertNull(o.get("given_name"));
    assertTrue(o.containsKey("middle_name"));
    assertNull(o.get("middle_name"));
    assertTrue(o.containsKey("nickname"));
    assertNull(o.get("nickname"));
    assertTrue(o.containsKey("preferred_username"));
    assertNull(o.get("preferred_username"));
    assertTrue(o.containsKey("profile"));
    assertNull(o.get("profile"));
    assertTrue(o.containsKey("picture"));
    assertNull(o.get("picture"));
    assertTrue(o.containsKey("website"));
    assertNull(o.get("website"));
    assertTrue(o.containsKey("gender"));
    assertNull(o.get("gender"));
    assertTrue(o.containsKey("birthdate"));
    assertNull(o.get("birthdate"));
    assertTrue(o.containsKey("zoneinfo"));
    assertNull(o.get("zoneinfo"));
    assertTrue(o.containsKey("locale"));
    assertNull(o.get("locale"));
    assertTrue(o.containsKey("updated_at"));
    assertNull(o.get("updated_at"));
    assertEquals(14, o.size());

    o = OIDCScopeValue.EMAIL.toClaimsRequestJSONObject();
    assertTrue(o.containsKey("email"));
    assertNull(o.get("email"));
    assertTrue(o.containsKey("email_verified"));
    assertNull(o.get("email_verified"));
    assertEquals(2, o.size());


    o = OIDCScopeValue.ADDRESS.toClaimsRequestJSONObject();
    assertTrue(o.containsKey("address"));
    assertNull(o.get("address"));
    assertEquals(1, o.size());

    o = OIDCScopeValue.PHONE.toClaimsRequestJSONObject();
    assertTrue(o.containsKey("phone_number"));
    assertNull(o.get("phone_number"));
    assertTrue(o.containsKey("phone_number_verified"));
    assertNull(o.get("phone_number_verified"));
    assertEquals(2, o.size());

    assertNull(OIDCScopeValue.OFFLINE_ACCESS.toClaimsRequestJSONObject());
  }
View Full Code Here

    assertEquals(CommonContentTypes.APPLICATION_JSON, httpResponse.getContentType());
    assertEquals("no-store", httpResponse.getCacheControl());
    assertEquals("no-cache", httpResponse.getPragma());
   
   
    JSONObject jsonObject = JSONObjectUtils.parseJSONObject(httpResponse.getContent())

    assertEquals(OAuth2Error.INVALID_REQUEST.getCode(), (String)jsonObject.get("error"));
    assertEquals(OAuth2Error.INVALID_REQUEST.getDescription(), (String)jsonObject.get("error_description"));
    assertEquals(ERROR_PAGE_URI.toString(), (String)jsonObject.get("error_uri"));
    assertEquals(3, jsonObject.size());
   
   
    r = TokenErrorResponse.parse(httpResponse);
   
    assertEquals(OAuth2Error.INVALID_REQUEST, r.getErrorObject());
View Full Code Here

      "     \"auth_time\": {\"essential\": true},\n" +
      "     \"acr\": {\"values\": [\"urn:mace:incommon:iap:silver\"] }\n" +
      "    }\n" +
      "  }\n";

    JSONObject jsonObject = JSONObjectUtils.parseJSONObject(json);

    ClaimsRequest claimsRequest = ClaimsRequest.parse(jsonObject);

    Set<String> idTokenClaimNames = claimsRequest.getIDTokenClaimNames(false);
    assertTrue(idTokenClaimNames.contains("auth_time"));
View Full Code Here

    assertTrue(r.getIDTokenClaimNames(false).contains("email"));
    assertTrue(r.getIDTokenClaimNames(false).contains("name"));
    assertEquals(2, r.getIDTokenClaims().size());

    JSONObject object = r.toJSONObject();
    assertEquals(1, object.size());

    JSONObject idTokenObject = (JSONObject)object.get("id_token");
    assertTrue(idTokenObject.containsKey("email"));
    assertNull(idTokenObject.get("email"));
    assertTrue(idTokenObject.containsKey("name"));
    assertNull(idTokenObject.get("name"));
    assertEquals(2, idTokenObject.size());

    r.removeIDTokenClaims("email");
    r.removeIDTokenClaims("name");

    assertFalse(r.getIDTokenClaimNames(false).contains("email"));
View Full Code Here

    assertTrue(r.getUserInfoClaimNames(false).contains("email"));
    assertTrue(r.getUserInfoClaimNames(false).contains("name"));
    assertEquals(2, r.getUserInfoClaims().size());

    JSONObject object = r.toJSONObject();
    assertEquals(1, object.size());

    JSONObject userInfoObject = (JSONObject)object.get("userinfo");
    assertTrue(userInfoObject.containsKey("email"));
    assertNull(userInfoObject.get("email"));
    assertTrue(userInfoObject.containsKey("name"));
    assertNull(userInfoObject.get("name"));
    assertEquals(2, userInfoObject.size());

    r.removeUserInfoClaims("email");
    r.removeUserInfoClaims("name");

    assertFalse(r.getUserInfoClaimNames(false).contains("email"));
View Full Code Here

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

    JSONObject o = metadata.toJSONObject();

    o.put("client_id", id.getValue());

    if (issueDate != null) {

      o.put("client_id_issued_at", issueDate.getTime() / 1000);
    }

    if (secret != null) {
      o.put("client_secret", secret.getValue());

      if (secret.getExpirationDate() != null) {
        o.put("client_secret_expires_at", secret.getExpirationDate().getTime() / 1000);
      } else {
        o.put("client_secret_expires_at", 0l);
      }
    }

    if (registrationURI != null) {

      o.put("registration_client_uri", registrationURI.toString());
    }

    if (accessToken != null) {

      o.put("registration_access_token", accessToken.getValue());
    }

    return o;
  }
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.