Package org.exoplatform.services.jcr.core

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


      super.tearDown();
   }

   public void testUpdateWhenParentHasRightsButChildNot() throws Exception
   {
      Session sessJohn = repository.login(new CredentialsImpl("john", "exo".toCharArray()));

      NodeImpl subNode = (NodeImpl)sessJohn.getRootNode().getNode("testRoot").addNode("testNode");
      subNode.addMixin("exo:privilegeable");
      sessJohn.save();

      NodeImpl testRoot = (NodeImpl)sessJohn.getRootNode().getNode("testRoot");

      testRoot.setPermission("mary", PermissionType.ALL);
      testRoot.setPermission("john", PermissionType.ALL);
      testRoot.removePermission(SystemIdentity.ANY);

      subNode.setPermission("mary", new String[]{PermissionType.READ, PermissionType.SET_PROPERTY});
      subNode.removePermission(SystemIdentity.ANY);
      sessJohn.save();
      sessJohn.logout();

      // login as Mary with no rights, and try to addmixin
      Session sessMary = repository.login(new CredentialsImpl("mary", "exo".toCharArray()));
      subNode = (NodeImpl)sessMary.getRootNode().getNode("testRoot").getNode("testNode");

      try
      {
         subNode.addMixin("mix:referenceable");
View Full Code Here


      if (System.getProperty("java.security.auth.login.config") == null)
      {
         System.setProperty("java.security.auth.login.config", loginConf);
      }

      credentials = new CredentialsImpl("admin", "admin".toCharArray());

      repositoryService = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
      repository = (RepositoryImpl)repositoryService.getDefaultRepository();

      session = (SessionImpl)repository.login(credentials, "ws");
View Full Code Here

         ManageableRepository repository = service.getRepository(repoEntry.getName());

         // add content
         Session session =
            repository.login(new CredentialsImpl("admin", "admin".toCharArray()), repository.getConfiguration()
               .getSystemWorkspaceName());
         session.getRootNode().addNode("test");
         session.save();
         session.logout();

         // copy repository configuration
         RepositoryEntry repositoryEntry = helper.copyRepositoryEntry(repository.getConfiguration());

         String newDatasourceName = helper.createDatasource();

         for (WorkspaceEntry ws : repositoryEntry.getWorkspaceEntries())
         {
            List<SimpleParameterEntry> parameters = ws.getContainer().getParameters();
            for (int i = 0; i <= parameters.size(); i++)
            {
               SimpleParameterEntry spe = parameters.get(i);
               if (spe.getName().equals("source-name"))
               {
                  parameters.add(i, new SimpleParameterEntry(spe.getName(), newDatasourceName));
                  break;
               }
            }
         }

         service.removeRepository(repository.getConfiguration().getName());

         try
         {
            service.getRepository(repository.getConfiguration().getName());
            fail();
         }
         catch (Exception e)
         {
         }

         // create new repository
         service.createRepository(repositoryEntry);
         service.getConfig().retain();

         newRepository = service.getRepository(repositoryEntry.getName());

         Session newSession = null;
         try
         {
            newSession =
               newRepository.login(new CredentialsImpl("admin", "admin".toCharArray()), newRepository
                  .getConfiguration().getSystemWorkspaceName());

            try
            {
               newSession.getRootNode().getNode("test");
View Full Code Here

      assertEquals(session.getUserID(), credentials.getUserID());

      assertEquals(0, session.getAttributeNames().length);
      assertNull(session.getAttribute("test"));

      CredentialsImpl c2 = new CredentialsImpl(this.credentials.getUserID(), credentials.getPassword());
      c2.setAttribute("test", "value");

      Session session2 = repository.login(c2);

      assertEquals(1, session2.getAttributeNames().length);
      assertEquals("value", session2.getAttribute("test"));
View Full Code Here

      assertEquals(session.getWorkspace().getSession(), session);
   }

   public void testImpersonate() throws LoginException, RepositoryException
   {
      Session session2 = session.impersonate(new CredentialsImpl("user", new char[0]));
      assertNotSame(session, session2);
      /*
       * 6.2.1 The new Session is tied to a new Workspace instance. In other
       * words, Workspace instances are not re-used.
       */
 
View Full Code Here

   {
      PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
      {
         public Object run() throws Exception
         {
            repository.login(new CredentialsImpl(IdentityConstants.SYSTEM, "".toCharArray()), repository.getSystemWorkspaceName());
            return null;
         }

      };
      try
View Full Code Here

      assertEquals("john add_node", folderA.getACL().getPermissionEntries().get(1).getAsString());
      assertEquals("john set_property", folderA.getACL().getPermissionEntries().get(2).getAsString());
      assertEquals("john remove", folderA.getACL().getPermissionEntries().get(3).getAsString());
     
     
      Session sessJohn = repository.login(new CredentialsImpl("john", "exo".toCharArray()), "ws");
     
      ExtendedNode folderB = (ExtendedNode)sessJohn.getRootNode().getNode("folderA").addNode("folderB", "nt:folder");
     
      folderB.addMixin("exo:privilegeable");
      folderB.setPermission("any", new String[]{"read"});
      sessJohn.save();
     
      assertEquals(5, folderB.getACL().getPermissionEntries().size());
      assertEquals("john read", folderB.getACL().getPermissionEntries().get(0).getAsString());
      assertEquals("john add_node", folderB.getACL().getPermissionEntries().get(1).getAsString());
      assertEquals("john set_property", folderB.getACL().getPermissionEntries().get(2).getAsString());
      assertEquals("john remove", folderB.getACL().getPermissionEntries().get(3).getAsString());
      assertEquals("any read", folderB.getACL().getPermissionEntries().get(4).getAsString());
     
      // Login as anonim.
      // Tthis session use on server side, thank SessionProvider.
      repository.login(new CredentialsImpl(IdentityConstants.ANONIM, "exo".toCharArray()), "ws");

      String path = getPathWS() + "/folderA/folderB";

      ContainerResponse response = service(WebDAVMethods.GET, path, "", null, null);
      assertEquals("Successful result expected (200), but actual is: " + response.getStatus(), 200, response.getStatus());
View Full Code Here

      container = StandaloneContainer.getInstance();

      if (System.getProperty("java.security.auth.login.config") == null)
         System.setProperty("java.security.auth.login.config", loginConf);

      credentials = new CredentialsImpl("root", "exo".toCharArray());

      repositoryService = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
      // container.start();
      repository = (RepositoryImpl)repositoryService.getDefaultRepository();
View Full Code Here

      if (System.getProperty("java.security.auth.login.config") == null)
      {
         System.setProperty("java.security.auth.login.config", loginConf);
      }

      credentials = new CredentialsImpl("admin", "admin".toCharArray());

      repositoryService = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
      repository = (RepositoryImpl)repositoryService.getDefaultRepository();

      session = (SessionImpl)repository.login(credentials, "ws");
View Full Code Here

      container = StandaloneContainer.getInstance();

      if (System.getProperty("java.security.auth.login.config") == null)
         System.setProperty("java.security.auth.login.config", loginConf);

      credentials = new CredentialsImpl("root", "exo".toCharArray());

      repositoryService = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
      // container.start();
      repository = (RepositoryImpl)repositoryService.getDefaultRepository();
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.