Package org.apache.sling.commons.json

Examples of org.apache.sling.commons.json.JSONObject


    //fetch the group profile json to verify the settings
    String getUrl = HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".json";
    Credentials creds = new UsernamePasswordCredentials("admin", "admin");
    String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
    assertNotNull(json);
    JSONObject jsonObj = new JSONObject(json);
    assertEquals(testGroupId, jsonObj.getString("marker"));
  }
View Full Code Here


    //fetch the group profile json to verify the settings
    String getUrl = HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".json";
    Credentials creds = new UsernamePasswordCredentials("admin", "admin");
    String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
    assertNotNull(json);
    JSONObject jsonObj = new JSONObject(json);
    assertEquals(testGroupId, jsonObj.getString("marker"));
    assertEquals("My Test Group", jsonObj.getString("displayName"));
    assertEquals("http://www.apache.org", jsonObj.getString("url"));
  }
View Full Code Here

    postParams.add(new NameValuePair("marker", testGroupId));
    Credentials creds = new UsernamePasswordCredentials("admin", "admin");
    String json = getAuthenticatedPostContent(creds, postUrl, CONTENT_TYPE_JSON, postParams, HttpServletResponse.SC_OK);

    //make sure the json response can be parsed as a JSON object
    JSONObject jsonObj = new JSONObject(json);
    assertNotNull(jsonObj);
 
View Full Code Here

    //fetch the JSON for the eacl to verify the settings.
    String getUrl = testFolderUrl + "/child.eacl.json";

    String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
    assertNotNull(json);
    JSONObject jsonObject = new JSONObject(json);
   
    JSONObject aceObject = jsonObject.optJSONObject(testUserId);
    assertNotNull(aceObject);

    String principalString = aceObject.optString("principal");
    assertEquals(testUserId, principalString);
   
    JSONArray grantedArray = aceObject.optJSONArray("granted");
    assertNotNull(grantedArray);
    assertEquals(1, grantedArray.length());
    Set<String> grantedPrivilegeNames = new HashSet<String>();
    for (int i=0; i < grantedArray.length(); i++) {
      grantedPrivilegeNames.add(grantedArray.getString(i));
    }
    H.assertPrivilege(grantedPrivilegeNames,true,"jcr:write");

    JSONArray deniedArray = aceObject.optJSONArray("denied");
    assertNull(deniedArray);

    JSONObject aceObject2 = jsonObject.optJSONObject(testUserId2);
    assertNotNull(aceObject2);

    String principalString2 = aceObject2.optString("principal");
    assertEquals(testUserId2, principalString2);
   
    JSONArray grantedArray2 = aceObject2.optJSONArray("granted");
    assertNotNull(grantedArray2);
    assertEquals(2, grantedArray2.length());
    Set<String> grantedPrivilegeNames2 = new HashSet<String>();
    for (int i=0; i < grantedArray2.length(); i++) {
      grantedPrivilegeNames2.add(grantedArray2.getString(i));
    }
    H.assertPrivilege(grantedPrivilegeNames2, true, "jcr:write");
    H.assertPrivilege(grantedPrivilegeNames2, true, "jcr:lockManagement");

    JSONArray deniedArray2 = aceObject2.optJSONArray("denied");
    assertNull(deniedArray2);
 
  }
View Full Code Here

    //fetch the JSON for the eacl to verify the settings.
    String getUrl = testFolderUrl + "/child.eacl.json";

    String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
    assertNotNull(json);
    JSONObject jsonObject = new JSONObject(json);
   
    JSONObject aceObject = jsonObject.optJSONObject(testUserId);
    assertNotNull(aceObject);

    String principalString = aceObject.optString("principal");
    assertEquals(testUserId, principalString);
   
    JSONArray grantedArray = aceObject.optJSONArray("granted");
    assertNotNull(grantedArray);
    assertEquals(1, grantedArray.length());
    Set<String> grantedPrivilegeNames = new HashSet<String>();
    for (int i=0; i < grantedArray.length(); i++) {
      grantedPrivilegeNames.add(grantedArray.getString(i));
    }
    H.assertPrivilege(grantedPrivilegeNames,true,"jcr:write");

    JSONArray deniedArray = aceObject.optJSONArray("denied");
    assertNull(deniedArray);
  }
View Full Code Here

    //fetch the JSON for the eacl to verify the settings.
    String getUrl = testFolderUrl + "/child.eacl.json";

    String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
    assertNotNull(json);
    JSONObject jsonObject = new JSONObject(json);
   
    JSONObject aceObject = jsonObject.optJSONObject(testUserId);
    assertNotNull(aceObject);

    String principalString = aceObject.optString("principal");
    assertEquals(testUserId, principalString);
   
    JSONArray grantedArray = aceObject.optJSONArray("granted");
    assertNotNull(grantedArray);
    assertEquals(1, grantedArray.length());
    Set<String> grantedPrivilegeNames = new HashSet<String>();
    for (int i=0; i < grantedArray.length(); i++) {
      grantedPrivilegeNames.add(grantedArray.getString(i));
    }
    H.assertPrivilege(grantedPrivilegeNames,true,"jcr:all");

    JSONArray deniedArray = aceObject.optJSONArray("denied");
    assertNull(deniedArray);
  }
View Full Code Here

    //fetch the JSON for the eacl to verify the settings.
    String getUrl = testFolderUrl + "/child.eacl.json";

    String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
    assertNotNull(json);
    JSONObject jsonObject = new JSONObject(json);
   
    JSONObject aceObject = jsonObject.optJSONObject(testUserId);
    assertNotNull(aceObject);

    String principalString = aceObject.optString("principal");
    assertEquals(testUserId, principalString);
   
    JSONArray grantedArray = aceObject.optJSONArray("granted");
    assertNotNull(grantedArray);
    assertEquals(1, grantedArray.length());
    Set<String> grantedPrivilegeNames = new HashSet<String>();
    for (int i=0; i < grantedArray.length(); i++) {
      grantedPrivilegeNames.add(grantedArray.getString(i));
    }
    H.assertPrivilege(grantedPrivilegeNames,true,"jcr:all");

    JSONArray deniedArray = aceObject.optJSONArray("denied");
    assertNull(deniedArray);
  }
View Full Code Here

    //fetch the JSON for the eacl to verify the settings.
    String getUrl = testFolderUrl + "/child.eacl.json";

    String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
    assertNotNull(json);
    JSONObject jsonObject = new JSONObject(json);
   
    JSONObject aceObject = jsonObject.optJSONObject(testUserId);
    assertNotNull(aceObject);

    String principalString = aceObject.optString("principal");
    assertEquals(testUserId, principalString);
   
    JSONArray grantedArray = aceObject.optJSONArray("granted");
    assertNotNull(grantedArray);
    assertTrue(grantedArray.length() >= 8);
    Set<String> grantedPrivilegeNames = new HashSet<String>();
    for (int i=0; i < grantedArray.length(); i++) {
      grantedPrivilegeNames.add(grantedArray.getString(i));
    }
    H.assertPrivilege(grantedPrivilegeNames,false,"jcr:all");
    H.assertPrivilege(grantedPrivilegeNames,false,"jcr:write");
    H.assertPrivilege(grantedPrivilegeNames,true,"jcr:read");
    H.assertPrivilege(grantedPrivilegeNames,true,"jcr:readAccessControl");
    H.assertPrivilege(grantedPrivilegeNames,true,"jcr:modifyAccessControl");
    H.assertPrivilege(grantedPrivilegeNames,true,"jcr:lockManagement");
    H.assertPrivilege(grantedPrivilegeNames,true,"jcr:versionManagement");
    H.assertPrivilege(grantedPrivilegeNames,true,"jcr:nodeTypeManagement");
    H.assertPrivilege(grantedPrivilegeNames,true,"jcr:retentionManagement");
    H.assertPrivilege(grantedPrivilegeNames,true,"jcr:lifecycleManagement");
    //jcr:write aggregate privileges should be denied
    H.assertPrivilege(grantedPrivilegeNames,false,"jcr:modifyProperties");
    H.assertPrivilege(grantedPrivilegeNames,false,"jcr:addChildNodes");
    H.assertPrivilege(grantedPrivilegeNames,false,"jcr:removeNode");
    H.assertPrivilege(grantedPrivilegeNames,false,"jcr:removeChildNodes");
   
   
    JSONArray deniedArray = aceObject.optJSONArray("denied");
    assertNotNull(deniedArray);
    assertEquals(1, deniedArray.length());
    Set<String> deniedPrivilegeNames = new HashSet<String>();
    for (int i=0; i < deniedArray.length(); i++) {
      deniedPrivilegeNames.add(deniedArray.getString(i));
View Full Code Here

    //fetch the JSON for the eacl to verify the settings.
    String getUrl = testFolderUrl + "/child.eacl.json";

    String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
    assertNotNull(json);
    JSONObject jsonObject = new JSONObject(json);
   
    JSONObject aceObject = jsonObject.optJSONObject(testUserId);
    assertNotNull(aceObject);

    String principalString = aceObject.optString("principal");
    assertEquals(testUserId, principalString);
   
    JSONArray grantedArray = aceObject.optJSONArray("granted");
    assertNotNull(grantedArray);
    assertTrue(grantedArray.length() >= 11);
    Set<String> grantedPrivilegeNames = new HashSet<String>();
    for (int i=0; i < grantedArray.length(); i++) {
      grantedPrivilegeNames.add(grantedArray.getString(i));
    }
    H.assertPrivilege(grantedPrivilegeNames,false,"jcr:all");
    H.assertPrivilege(grantedPrivilegeNames,false,"jcr:write");
    H.assertPrivilege(grantedPrivilegeNames,true,"jcr:read");
    H.assertPrivilege(grantedPrivilegeNames,true,"jcr:readAccessControl");
    H.assertPrivilege(grantedPrivilegeNames,true,"jcr:modifyAccessControl");
    H.assertPrivilege(grantedPrivilegeNames,true,"jcr:lockManagement");
    H.assertPrivilege(grantedPrivilegeNames,true,"jcr:versionManagement");
    H.assertPrivilege(grantedPrivilegeNames,true,"jcr:nodeTypeManagement");
    H.assertPrivilege(grantedPrivilegeNames,true,"jcr:retentionManagement");
    H.assertPrivilege(grantedPrivilegeNames,true,"jcr:lifecycleManagement");
    H.assertPrivilege(grantedPrivilegeNames,true,"jcr:modifyProperties");
    H.assertPrivilege(grantedPrivilegeNames,true,"jcr:addChildNodes");
    H.assertPrivilege(grantedPrivilegeNames,true,"jcr:removeChildNodes");

    JSONArray deniedArray = aceObject.optJSONArray("denied");
    assertNotNull(deniedArray);
    assertEquals(1, deniedArray.length());
    Set<String> deniedPrivilegeNames = new HashSet<String>();
    for (int i=0; i < deniedArray.length(); i++) {
      deniedPrivilegeNames.add(deniedArray.getString(i));
View Full Code Here

    //fetch the JSON for the eacl to verify the settings.
    String getUrl = testFolderUrl + "/child.eacl.json";

    String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
    assertNotNull(json);
    JSONObject jsonObject = new JSONObject(json);
   
    JSONObject aceObject = jsonObject.optJSONObject(testUserId);
    assertNotNull(aceObject);

    String principalString = aceObject.optString("principal");
    assertEquals(testUserId, principalString);
   
    JSONArray grantedArray = aceObject.optJSONArray("granted");
    assertNull(grantedArray);
   
    JSONArray deniedArray = aceObject.optJSONArray("denied");
    assertNotNull(deniedArray);
    assertEquals(1, deniedArray.length());
    Set<String> deniedPrivilegeNames = new HashSet<String>();
    for (int i=0; i < deniedArray.length(); i++) {
      deniedPrivilegeNames.add(deniedArray.getString(i));
View Full Code Here

TOP

Related Classes of org.apache.sling.commons.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.