Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-2193

Calling Node.getNodes() throws java.util.NoSuchElementException when applying ACLs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 4.0.0.Alpha2
    • 3.7.2.Final
    • JCR
    • None
    • Hide

      This is a test case to reproduce this issue:

      org.modeshape.jcr.security.AccessControlManagerTest.java
          @Test
          public void shouldAllowReadAccessibleNodes() throws Exception {
              AccessControlList acl = getACL("/");
              acl.addAccessControlEntry(SimplePrincipal.newInstance("anonymous"),
                      new Privilege[] {acm.privilegeFromName(Privilege.JCR_ALL)});
              acm.setPolicy("/", acl);
      
              Node root = session.getRootNode();
              Node aircraft = root.addNode("aircraft");
              Node vans = root.addNode("vans");
              assertThat(aircraft, is(notNullValue()));
              assertThat(vans, is(notNullValue()));
      
              AccessControlList acl1 = getACL("/aircraft");
              acl1.addAccessControlEntry(SimplePrincipal.newInstance("Admin"),
                      new Privilege[] {acm.privilegeFromName(Privilege.JCR_ALL)});
              acl1.addAccessControlEntry(SimplePrincipal.newInstance("anonymous"),
                      new Privilege[] {acm.privilegeFromName(Privilege.JCR_READ)});
      
              acm.setPolicy("/aircraft", acl1);
      
              AccessControlList acl2 = getACL("/vans");
              acl2.addAccessControlEntry(SimplePrincipal.newInstance("user"),
                      new Privilege[] {acm.privilegeFromName(Privilege.JCR_ALL)});
              /* No Access to "anonymous" on "vans" node
              acl2.addAccessControlEntry(SimplePrincipal.newInstance("anonymous"),
                      new Privilege[] {acm.privilegeFromName(Privilege.JCR_READ)});
              */
      
              acm.setPolicy("/vans", acl2);
      
              session.save();
      
              root = session.getRootNode();
              NodeIterator ni = root.getNodes();
              while(ni.hasNext()){
                  Node n = ni.nextNode();
              }
          }
      
      Show
      This is a test case to reproduce this issue: org.modeshape.jcr.security.AccessControlManagerTest.java @Test public void shouldAllowReadAccessibleNodes() throws Exception { AccessControlList acl = getACL( "/" ); acl.addAccessControlEntry(SimplePrincipal.newInstance( "anonymous" ), new Privilege[] {acm.privilegeFromName(Privilege.JCR_ALL)}); acm.setPolicy( "/" , acl); Node root = session.getRootNode(); Node aircraft = root.addNode( "aircraft" ); Node vans = root.addNode( "vans" ); assertThat(aircraft, is(notNullValue())); assertThat(vans, is(notNullValue())); AccessControlList acl1 = getACL( "/aircraft" ); acl1.addAccessControlEntry(SimplePrincipal.newInstance( "Admin" ), new Privilege[] {acm.privilegeFromName(Privilege.JCR_ALL)}); acl1.addAccessControlEntry(SimplePrincipal.newInstance( "anonymous" ), new Privilege[] {acm.privilegeFromName(Privilege.JCR_READ)}); acm.setPolicy( "/aircraft" , acl1); AccessControlList acl2 = getACL( "/vans" ); acl2.addAccessControlEntry(SimplePrincipal.newInstance( "user" ), new Privilege[] {acm.privilegeFromName(Privilege.JCR_ALL)}); /* No Access to "anonymous" on "vans" node acl2.addAccessControlEntry(SimplePrincipal.newInstance( "anonymous" ), new Privilege[] {acm.privilegeFromName(Privilege.JCR_READ)}); */ acm.setPolicy( "/vans" , acl2); session.save(); root = session.getRootNode(); NodeIterator ni = root.getNodes(); while (ni.hasNext()){ Node n = ni.nextNode(); } }

      Calling

      Node.getNodes()

      throws

      java.util.NoSuchElementException.

      This happened when one or more child nodes are not accessible for the current session.

              hchiorean Horia Chiorean (Inactive)
              m.sarhan_jira Mouaffak Sarhan (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: