コード例 #1
0
  @Override
  public boolean hasPrivileges(final String absPath, final Privilege[] privileges)
      throws PathNotFoundException, RepositoryException {

    if (supportPrivileges) {
      // if the node is created in the same session, return true
      for (Item item : session.getNewItems()) {
        if (item.getPath().equals(absPath)) {
          return true;
        }
      }

      // check privilege names
      return hasPrivilegesLegacy(absPath, privileges);
    } else {
      // check ACLs
      Set<String> privs = new HashSet<>();
      for (Privilege privilege : privileges) {
        privs.add(privilege.getName());
      }
      String mountPoint = session.getRepository().getStoreProvider().getMountPoint();
      Session securitySession =
          JCRSessionFactory.getInstance()
              .getCurrentSystemSession(session.getWorkspace().getName(), null, null);
      PathWrapper pathWrapper =
          new ExternalPathWrapperImpl(
              StringUtils.equals(absPath, "/") ? mountPoint : mountPoint + absPath,
              securitySession);
      return AccessManagerUtils.isGranted(
          pathWrapper,
          privs,
          securitySession,
          jahiaPrincipal,
          workspaceName,
          false,
          pathPermissionCache,
          compiledAcls,
          registry);
    }
  }
コード例 #2
0
  @Override
  public Privilege[] getPrivileges(final String absPath)
      throws PathNotFoundException, RepositoryException {

    JCRNodeWrapper node =
        JCRSessionFactory.getInstance()
            .getCurrentSystemSession(workspaceName, null, null)
            .getNode(session.getRepository().getStoreProvider().getMountPoint() + absPath);
    Privilege[] privileges;
    if (supportPrivileges) {
      privileges = getPrivilegesLegacy(absPath);
    } else {
      privileges = AccessManagerUtils.getPrivileges(node, jahiaPrincipal, registry);
    }
    // filter some privileges in some specific cases, for avoid some operation from edit engines
    List<Privilege> privilegeToFilter = getPrivilegesToFilter(node.getRealNode());
    if (privilegeToFilter.size() > 0) {
      return filterPrivileges(privileges, privilegeToFilter);
    } else {
      return privileges;
    }
  }