protected JcrRepositoryMonitor( JcrSession session ) throws RepositoryException { this.session = session; this.permitted = session.hasPermission("/", ModeShapePermissions.MONITOR); }
@Override public boolean hasPermission( String absPath, String actions ) throws RepositoryException { checkLive(); CheckArg.isNotEmpty(absPath, "absPath"); PathSupplier pathSupplier = pathSupplierFor(absolutePathFor(absPath)); String[] actionsArray = actions.split(","); String workspaceName = this.workspace().getName(); return hasPermission(workspaceName, pathSupplier, actionsArray) && hasPermissionOnExternalPath(pathSupplier, actionsArray); }
protected JcrRepositoryMonitor( JcrSession session ) throws RepositoryException { this.session = session; this.permitted = session.hasPermission("/", ModeShapePermissions.MONITOR); }
@Override public boolean hasPermission( String absPath, String actions ) throws RepositoryException { checkLive(); CheckArg.isNotEmpty(absPath, "absPath"); PathSupplier pathSupplier = pathSupplierFor(absolutePathFor(absPath)); String[] actionsArray = actions.split(","); String workspaceName = this.workspace().getName(); return hasPermission(workspaceName, pathSupplier, actionsArray) && hasPermissionOnExternalPath(pathSupplier, actionsArray); }
@Override public Node nodeFrom( ChildReference ref ) { try { AbstractJcrNode node = session.node(ref.getKey(), null, parentKey); if (checkPermission && !node.isExternal() && !session.hasPermission(node.getPath(), ModeShapePermissions.READ)) { return null; } return node; } catch (RepositoryException e) { return null; } } }
@Override public Node nodeFrom( ChildReference ref ) { try { AbstractJcrNode node = session.node(ref.getKey(), null, parentKey); if (checkPermission && !node.isExternal() && !session.hasPermission(node.getPath(), ModeShapePermissions.READ)) { return null; } return node; } catch (RepositoryException e) { return null; } } }
private void assertPermission( boolean shouldHave, String absPath, String... actions ) throws RepositoryException { StringBuilder actionsBuilder = new StringBuilder(); List<String> actionsList = new ArrayList<String>(Arrays.asList(actions)); for (Iterator<String> actionsIterator = actionsList.iterator(); actionsIterator.hasNext();) { actionsBuilder.append(actionsIterator.next()); if (actionsIterator.hasNext()) { actionsBuilder.append(","); } } String actionsString = actionsBuilder.toString(); if (shouldHave) { assertTrue(session.hasPermission(absPath, actionsString)); session.checkPermission(absPath, actionsString); } else { assertFalse(session.hasPermission(absPath, actionsString)); try { session.checkPermission(absPath, actionsString); fail("There permissions " + actionsString + " should not be valid on " + absPath); } catch (AccessControlException e) { // expected } } }
void checkPermission( String workspaceName, PathSupplier pathSupplier, String... actions ) throws AccessDeniedException { CheckArg.isNotEmpty(actions, "actions"); if (hasPermission(workspaceName, pathSupplier, actions)) return; String pathAsString = "<unknown>"; if (pathSupplier != null) { try { pathAsString = pathSupplier.getAbsolutePath().getString(namespaces()); } catch (ItemNotFoundException e) { // Node was somehow removed from this session } } throw new AccessDeniedException(JcrI18n.permissionDenied.text(pathAsString, actions)); }
void checkPermission( String workspaceName, PathSupplier pathSupplier, String... actions ) throws AccessDeniedException { CheckArg.isNotEmpty(actions, "actions"); if (hasPermission(workspaceName, pathSupplier, actions)) return; String pathAsString = "<unknown>"; if (pathSupplier != null) { try { pathAsString = pathSupplier.getAbsolutePath().getString(namespaces()); } catch (ItemNotFoundException e) { // Node was somehow removed from this session } } throw new AccessDeniedException(JcrI18n.permissionDenied.text(pathAsString, actions)); }
if (relativePath.equals(".")) return true; if (relativePath.equals("..")) { return !isRoot() && session.hasPermission(this.getParent().getPath(), ModeShapePermissions.READ); if (path.getLastSegment().isSelfReference()) return true; if (path.getLastSegment().isParentReference()) { return !isRoot() && session.hasPermission(this.getParent().getPath(), ModeShapePermissions.READ); try { AbstractJcrNode node = session().node(node(), path); return node != null && session().hasPermission(node.getPath(), ModeShapePermissions.READ); } catch (PathNotFoundException e) { return false; return session.hasPermission(node.getPath(), ModeShapePermissions.READ);
if (relativePath.equals(".")) return true; if (relativePath.equals("..")) { return !isRoot() && session.hasPermission(this.getParent().getPath(), ModeShapePermissions.READ); if (path.getLastSegment().isSelfReference()) return true; if (path.getLastSegment().isParentReference()) { return !isRoot() && session.hasPermission(this.getParent().getPath(), ModeShapePermissions.READ); try { AbstractJcrNode node = session().node(node(), path); return node != null && session().hasPermission(node.getPath(), ModeShapePermissions.READ); } catch (PathNotFoundException e) { return false; return session.hasPermission(node.getPath(), ModeShapePermissions.READ);