/** @see AccessManager#isGranted(ItemId, int) */ public boolean isGranted(ItemId id, int actions) throws ItemNotFoundException, RepositoryException { checkInitialized(); if (actions == READ && compiledPermissions.canReadAll()) { return true; } else { int perm = 0; if ((actions & READ) == READ) { perm |= Permission.READ; } if ((actions & WRITE) == WRITE) { if (id.denotesNode()) { // TODO: check again if correct perm |= Permission.SET_PROPERTY; perm |= Permission.ADD_NODE; } else { perm |= Permission.SET_PROPERTY; } } if ((actions & REMOVE) == REMOVE) { perm |= (id.denotesNode()) ? Permission.REMOVE_NODE : Permission.REMOVE_PROPERTY; } Path path = hierMgr.getPath(id); return isGranted(path, perm); } }
@Override public boolean canRead(Path itemPath, ItemId itemId) throws RepositoryException { if ((itemId != null && "cafebabe-cafe-babe-cafe-babecafebabe".equals(itemId.toString())) || (itemPath != null && "/".equals(itemPath.toString()))) { // quick check - allow access to root to all like in old mgnl security return true; } if (itemPath == null) { // we deal only with permissions on nodes if (!itemId.denotesNode()) { itemId = ((PropertyId) itemId).getParentId(); } synchronized (monitor) { if (readCache.containsKey(itemId)) { return readCache.get(itemId); } itemPath = session.getHierarchyManager().getPath(itemId); boolean canRead = canRead(itemPath, itemId); readCache.put(itemId, canRead); return canRead; } } String path = pathResolver.getJCRPath(itemPath); log.debug("Read request for " + path + " :: " + itemId); return ami.isGranted(path, Permission.READ); }
/** {@inheritDoc} */ public boolean hasItemState(ItemId id) { if (id instanceof NodeId) { if (nodes.containsKey(id)) { return true; } else if (id.equals(rootNodeId)) { return true; } else { return internalHasNodeState((NodeId) id); } } else { return internalHasPropertyState((PropertyId) id); } }
/** * invalidates the item * * @param id * @param recursive */ public void invalidateItem(ItemId id, boolean recursive) { VirtualNodeState state = id.equals(rootNodeId) ? root : (VirtualNodeState) nodes.get(id); if (state != null) { if (recursive) { VirtualPropertyState[] props = state.getProperties(); for (int i = 0; i < props.length; i++) { props[i].notifyStateUpdated(); } for (ChildNodeEntry pe : state.getChildNodeEntries()) { invalidateItem(pe.getId(), true); } } state.notifyStateUpdated(); } }
/** {@inheritDoc} */ public ItemState getItemState(ItemId id) throws NoSuchItemStateException, ItemStateException { if (id instanceof NodeId) { ItemState s; if (nodes.containsKey(id)) { s = nodes.get(id); } else if (id.equals(rootNodeId)) { s = getRootState(); } else { s = cache(internalGetNodeState((NodeId) id)); } return s; } else { return internalGetPropertyState((PropertyId) id); } }
/** {@inheritDoc} */ public boolean isVirtualRoot(ItemId id) { return id.equals(rootNodeId); }