Package org.exoplatform.services.jcr.core

Examples of org.exoplatform.services.jcr.core.CredentialsImpl


            "SELECT * FROM " + node.getPrimaryNodeType().getName() + " WHERE jcr:path LIKE '/" + TEST_NAME + "'",
            Query.SQL).execute();
      assertEquals(1, getActualSize(res));

      // Search in other jcr - session
      Credentials cred = new CredentialsImpl("exo", "exo".toCharArray());
      Session sess = repository.login(cred, "ws");

      qManager = sess.getWorkspace().getQueryManager();
      res =
         qManager.createQuery(
View Full Code Here


      // the same after save() and re-retrieve
      session.save();
      node = (ExtendedNode)session.getRootNode().getNode("testACNode");

      Session session1 = repository.login(new CredentialsImpl("mary", "exo".toCharArray()));
      session1.getRootNode().getNode("testACNode");

      acl = node.getACL();
      assertEquals(session.getUserID(), acl.getOwner());
View Full Code Here

      // ACL is:
      // Owner = exo
      // ADD_NODE and READ permissions for john
      // check permission for john - ADD_NODE and READ allowed
      Session session1 = repository.login(new CredentialsImpl("john", "exo".toCharArray()));
      session1.checkPermission("/accessTestRoot/testSessionCheckPermission", PermissionType.READ);
      try
      {
         session1.checkPermission("/accessTestRoot/testSessionCheckPermission", PermissionType.SET_PROPERTY);
         fail("AccessControlException should have been thrown ");
      }
      catch (AccessControlException e)
      {
      }

      // check permission for exo2 - nothing allowed
      Session session2 = repository.login(new CredentialsImpl("mary", "exo".toCharArray()));
      try
      {
         session2.checkPermission("/accessTestRoot/testSessionCheckPermission", PermissionType.READ);
         fail("AccessControlException should have been thrown ");
      }
View Full Code Here

      // ACL is:
      // Owner = exo
      // READ permissions for john

      // check permission for john - READ allowed
      Session session1 = repository.login(new CredentialsImpl("john", "exo".toCharArray()));
      session1.getItem("/accessTestRoot/testRead");
      session1.getItem("/accessTestRoot/testRead/jcr:primaryType");
      session1.getItem("/accessTestRoot/testRead/node1");
      // primartType, mixinTypes, permissions, owner
      assertEquals(4, ((Node)session1.getItem("/accessTestRoot/testRead")).getProperties().getSize());

      Node n1 = (Node)session1.getItem("/accessTestRoot");
      assertEquals(1, n1.getNodes().getSize());

      // check permission for exo2 - nothing allowed
      Session session2 = repository.login(new CredentialsImpl("mary", "exo".toCharArray()));
      try
      {
         session2.getItem("/accessTestRoot/testRead");
         fail("AccessDeniedException should have been thrown ");
      }
View Full Code Here

      assertEquals(credentials.getUserID(), ((ExtendedNode)accessTestRoot.getNode("testAddNode")).getACL().getOwner());

      accessTestRoot.getNode("testAddNode").addNode("ownersNode");
      session.save();

      Session session1 = repository.login(new CredentialsImpl("mary", "exo".toCharArray()));

      session1.getRootNode().getNode("accessTestRoot/testAddNode").addNode("illegal");

      try
      {
         session1.save();
         fail("AccessDeniedException should have been thrown ");
      }
      catch (AccessDeniedException e)
      {
         session1.refresh(false);
      }

      session1 = repository.login(new CredentialsImpl("john", "exo".toCharArray()));
      session1.getRootNode().getNode("accessTestRoot/testAddNode").addNode("legal");
      session1.save();

      NodeImpl addNode = (NodeImpl)session1.getRootNode().getNode("accessTestRoot/testAddNode");
      addNode.setProperty("illegal", "test");
View Full Code Here

      assertEquals(credentials.getUserID(), ((ExtendedNode)session.getRootNode().getNode(
         "accessTestRoot/testModifyAndReadNode")).getACL().getOwner());
      session.getRootNode().getNode("accessTestRoot/testModifyAndReadNode").addNode("ownersNode");
      session.save();

      Session session1 = repository.login(new CredentialsImpl("john", "exo".toCharArray()));

      session1 = repository.login(new CredentialsImpl("john", "exo".toCharArray()));
      session1.getRootNode().getNode("accessTestRoot/testModifyAndReadNode").setProperty("legal", "test");
      session1.getRootNode().getNode("accessTestRoot/testModifyAndReadNode").setProperty("illegal", "test");
      session1.save();

      // session.getItem("/accessTestRoot/testModifyAndReadNode/legal");

      session1.getRootNode().getProperty("accessTestRoot/testModifyAndReadNode/legal").remove();
      session1.save();

      // john
      session1.getRootNode().getNode("accessTestRoot/testModifyAndReadNode").getProperty("illegal");
      assertEquals(1, session1.getRootNode().getNode("accessTestRoot/testModifyAndReadNode").getProperties("illegal")
         .getSize());

      Session session2 = repository.login(new CredentialsImpl("mary", "exo".toCharArray()));
      session2.getRootNode().getNode("accessTestRoot/testModifyAndReadNode").getProperty("illegal").remove();

      try
      {
         // exo2
View Full Code Here

      // ACL is:
      // Owner = exo
      // ALL permissions for john
      // READ permissions for exo2

      Session session1 = repository.login(new CredentialsImpl("john", "exo".toCharArray()));
      Session session2 = repository.login(new CredentialsImpl("mary", "exo".toCharArray()));

      session1.checkPermission("/accessTestRoot/testCheckAndCleanPermissions", PermissionType.ADD_NODE);

      try
      {
View Full Code Here

      node.addMixin("exo:privilegeable");
      node.setPermission("john", PermissionType.ALL);
      String owner = node.getACL().getOwner();
      assertEquals(8, node.getACL().getPermissionEntries().size());
      accessTestRoot.save();
      Session session1 = repository.login(new CredentialsImpl("john", "exo".toCharArray()));
      NodeImpl node1 = (NodeImpl)session1.getRootNode().getNode("accessTestRoot/testSetAndRemovePermission");
      assertEquals(8, node1.getACL().getPermissionEntries().size());
      assertEquals(node1.getACL().getOwner(), owner);
   }
View Full Code Here

      assertEquals(PermissionType.ALL.length * 2, node.getACL().getPermissionEntries().size());

      node.setPermission("mary", PermissionType.ALL);
      accessTestRoot.save();

      Session session1 = repository.login(new CredentialsImpl("mary", "exo".toCharArray()));
      ExtendedNode testRemoveSpecifiedNode =
         (ExtendedNode)session1.getRootNode().getNode("accessTestRoot").getNode("testRemoveSpecified");
      testRemoveSpecifiedNode.removePermission(IdentityConstants.ANY);

      assertTrue(accessManager.hasPermission(testRemoveSpecifiedNode.getACL(), PermissionType.READ,
View Full Code Here

      session1.save();
   }

   public void testOperationsByOwner() throws Exception
   {
      Session session1 = repository.login(new CredentialsImpl("john", "exo".toCharArray()));
      Node accessTestRoot1 = session1.getRootNode().getNode("accessTestRoot");

      accessTestRoot1.addMixin("exo:privilegeable");

      Node testByOwnerNode = accessTestRoot1.addNode("testByOwnerNode");
      testByOwnerNode.addMixin("exo:owneable");
      testByOwnerNode.addMixin("exo:privilegeable");

      session1.save();
      session1.logout();

      accessTestRoot = (ExtendedNode)session.getRootNode().getNode("accessTestRoot");

      accessTestRoot.setPermission(accessTestRoot.getSession().getUserID(), PermissionType.ALL);
      accessTestRoot.removePermission("john");
      accessTestRoot.removePermission(IdentityConstants.ANY);
      accessTestRoot.setPermission("john", new String[]{PermissionType.READ});

      ExtendedNode testByOwnerNodeSystem = (ExtendedNode)accessTestRoot.getNode("testByOwnerNode");
      testByOwnerNodeSystem.setPermission(accessTestRoot.getSession().getUserID(), PermissionType.ALL);
      testByOwnerNodeSystem.removePermission("john");
      testByOwnerNodeSystem.removePermission(IdentityConstants.ANY);
      testByOwnerNodeSystem.setPermission("john", new String[]{PermissionType.READ});

      session.save();

      session1 = repository.login(new CredentialsImpl("john", "exo".toCharArray()));
      accessTestRoot1 = session1.getRootNode().getNode("accessTestRoot");
      testByOwnerNode = accessTestRoot1.getNode("testByOwnerNode");
      try
      {
         Property prop = testByOwnerNode.setProperty("prop1", "val1");
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.core.CredentialsImpl

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.