Package org.apache.sling.commons.json

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


    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


    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

    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

    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));
    }
    H.assertPrivilege(deniedPrivilegeNames, true, "jcr:write");
  }
View Full Code Here

    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));
    }
    H.assertPrivilege(deniedPrivilegeNames, true, "jcr:removeNode");
  }
View Full Code Here

    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));
    }
    H.assertPrivilege(deniedPrivilegeNames, true, "jcr:all");
  }
View Full Code Here

    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));
    }
    H.assertPrivilege(deniedPrivilegeNames, true, "jcr:all");
  }
View Full Code Here

        new RetryLoop(new Condition() {

            public boolean isTrue() throws Exception {
                String result = getContent(queryUrl, CONTENT_TYPE_JSON);

                JSONArray results = new JSONArray(result);

                if (results.length() == 0) {
                    return false;
                }

                String expectedPath = SERVLET_CONTEXT + "/" + folderName + "/" + fileName + "/jcr:content";

                for (int i = 0; i < results.length(); i++) {
                    JSONObject object = results.getJSONObject(i);
                    if (expectedPath.equals(object.getString("jcr:path"))) {
                        return true;
                    }
                }
View Full Code Here

    testUserId = createTestUser();

        Credentials creds = new UsernamePasswordCredentials("admin", "admin");

    // verify that the members array exists, but is empty
    JSONArray members = getTestGroupMembers(creds);
        assertEquals(0, members.length());

        JSONArray memberships = getTestUserMemberships(creds);
        assertEquals(0, memberships.length());

        String postUrl = HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".update.html";

        // add a group member
    List<NameValuePair> postParams = new ArrayList<NameValuePair>();
    postParams.add(new NameValuePair(":member", testUserId));
        assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null);

        members = getTestGroupMembers(creds);
        assertEquals(1, members.length());
        assertEquals("/system/userManager/user/" + testUserId, members.getString(0));

        memberships = getTestUserMemberships(creds);
        assertEquals(1, memberships.length());
        assertEquals("/system/userManager/group/" + testGroupId, memberships.getString(0));

        // delete a group member
    postParams.clear();
    postParams.add(new NameValuePair(":member@Delete", testUserId));
        assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null);

        members = getTestGroupMembers(creds);
        assertEquals(0, members.length());

        memberships = getTestUserMemberships(creds);
        assertEquals(0, memberships.length());

  }
View Full Code Here

      String getUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".json";
        assertAuthenticatedHttpStatus(creds, getUrl, HttpServletResponse.SC_OK, null); //make sure the profile request returns some data
        String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
        assertNotNull(json);
        JSONObject jsonObj = new JSONObject(json);
        JSONArray memberships = jsonObj.getJSONArray("memberOf");
        return memberships;
    }
View Full Code Here

TOP

Related Classes of org.apache.sling.commons.json.JSONArray

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.