/** * Checks if the current session has version management permission * * @throws AccessDeniedException if version management is not allowed * @throws RepositoryException if an error occurs */ private void checkVersionManagementPermission() throws RepositoryException { try { sessionContext.getAccessManager().checkPermission(getPrimaryPath(), Permission.VERSION_MNGMT); } catch (ItemNotFoundException e) { // ignore. } }
/** * Checks if the current session has version management permission * * @throws AccessDeniedException if version management is not allowed * @throws RepositoryException if an error occurs */ private void checkVersionManagementPermission() throws RepositoryException { try { sessionContext.getAccessManager().checkPermission(getPrimaryPath(), Permission.VERSION_MNGMT); } catch (ItemNotFoundException e) { // ignore. } }
private void checkPermission(ItemImpl item, int perm) throws RepositoryException { if (perm > Permission.NONE) { SessionImpl sImpl = (SessionImpl) item.getSession(); AccessManager acMgr = sImpl.getAccessManager(); Path path = item.getPrimaryPath(); acMgr.checkPermission(path, perm); } }
private void checkPermission(ItemImpl item, int perm) throws RepositoryException { if (perm > Permission.NONE) { SessionImpl sImpl = (SessionImpl) item.getSession(); AccessManager acMgr = sImpl.getAccessManager(); Path path = item.getPrimaryPath(); acMgr.checkPermission(path, perm); } }
/** */ public void testCheckPermissionWithNoPermissionFlag() throws RepositoryException, NotExecutableException { AccessManager acMgr = getAccessManager(superuser); NodeId id = (NodeId) getItemId(superuser.getItem(testRootNode.getPath())); // NOTE: backwards compatibility. // for deprecated method: invalid perm-flags will be ignored acMgr.checkPermission(id, AccessManager.READ - 1); }
public void testCheckPermissionWithInvalidPermission() throws RepositoryException, NotExecutableException { AccessManager acMgr = getAccessManager(superuser); NodeId id = (NodeId) getItemId(superuser.getItem(testRootNode.getPath())); // NOTE: backwards compatibility. // for deprecated method: invalid perm-flags will be ignored acMgr.checkPermission(id, AccessManager.READ | AccessManager.WRITE | AccessManager.REMOVE + 1); }
public void testCheckPermissionReadOnlySession() throws RepositoryException, NotExecutableException { Session s = getHelper().getReadOnlySession(); try { AccessManager acMgr = getAccessManager(s); NodeId id = (NodeId) getItemId(s.getItem(testRootNode.getPath())); acMgr.checkPermission(id, AccessManager.READ); try { acMgr.checkPermission(id, AccessManager.WRITE); fail(); } catch (AccessDeniedException e) { // success } try { acMgr.checkPermission(id, AccessManager.WRITE | AccessManager.REMOVE); fail(); } catch (AccessDeniedException e) { // success } } finally { s.logout(); } }
public void testCheckPermissionWithUnknowId() throws RepositoryException, NotExecutableException { Session s = getHelper().getReadOnlySession(); NodeId id = NodeId.randomId(); try { AccessManager acMgr = getAccessManager(s); acMgr.checkPermission(id, AccessManager.READ); fail("AccessManager.checkPermission should throw ItemNotFoundException with a random (unknown) item id."); } catch (ItemNotFoundException e) { // ok } finally { s.logout(); } }
/** * @see RetentionManager#getHolds(String) */ public Hold[] getHolds(String absPath) throws PathNotFoundException, AccessDeniedException, RepositoryException { NodeImpl n = (NodeImpl) session.getNode(absPath); session.getAccessManager().checkPermission(session.getQPath(absPath), Permission.RETENTION_MNGMT); Hold[] holds; if (n.isNodeType(REP_RETENTION_MANAGEABLE) && n.hasProperty(REP_HOLD)) { holds = HoldImpl.createFromProperty(n.getProperty(REP_HOLD), n.getNodeId()); } else { holds = new Hold[0]; } return holds; }
/** * @see RetentionManager#getHolds(String) */ public Hold[] getHolds(String absPath) throws PathNotFoundException, AccessDeniedException, RepositoryException { NodeImpl n = (NodeImpl) session.getNode(absPath); session.getAccessManager().checkPermission(session.getQPath(absPath), Permission.RETENTION_MNGMT); Hold[] holds; if (n.isNodeType(REP_RETENTION_MANAGEABLE) && n.hasProperty(REP_HOLD)) { holds = HoldImpl.createFromProperty(n.getProperty(REP_HOLD), n.getNodeId()); } else { holds = new Hold[0]; } return holds; }
/** * @see RetentionManager#getRetentionPolicy(String) */ public RetentionPolicy getRetentionPolicy(String absPath) throws PathNotFoundException, AccessDeniedException, RepositoryException { NodeImpl n = (NodeImpl) session.getNode(absPath); session.getAccessManager().checkPermission(session.getQPath(absPath), Permission.RETENTION_MNGMT); RetentionPolicy rPolicy = null; if (n.isNodeType(REP_RETENTION_MANAGEABLE) && n.hasProperty(REP_RETENTION_POLICY)) { String jcrName = n.getProperty(REP_RETENTION_POLICY).getString(); rPolicy = new RetentionPolicyImpl(jcrName, n.getNodeId(), session); } return rPolicy; }
/** * @see RetentionManager#getRetentionPolicy(String) */ public RetentionPolicy getRetentionPolicy(String absPath) throws PathNotFoundException, AccessDeniedException, RepositoryException { NodeImpl n = (NodeImpl) session.getNode(absPath); session.getAccessManager().checkPermission(session.getQPath(absPath), Permission.RETENTION_MNGMT); RetentionPolicy rPolicy = null; if (n.isNodeType(REP_RETENTION_MANAGEABLE) && n.hasProperty(REP_RETENTION_POLICY)) { String jcrName = n.getProperty(REP_RETENTION_POLICY).getString(); rPolicy = new RetentionPolicyImpl(jcrName, n.getNodeId(), session); } return rPolicy; }
context.getAccessManager().checkPermission(path, permissions);
context.getAccessManager().checkPermission(path, permissions);
/** * {@inheritDoc} * @throws LockException if this <code>Session</code> is not the lock holder * or if this <code>Lock</code> is not alive. */ public void refresh() throws LockException, RepositoryException { if (!isLive()) { info.throwLockException( "Lock is not live any more", (SessionImpl) node.getSession()); } else if (!isLockOwningSession()) { info.throwLockException( "Session does not hold lock.", (SessionImpl) node.getSession()); } else { // make sure the current session has sufficient privileges to refresh // the lock. SessionImpl session = (SessionImpl) node.getSession(); session.getAccessManager().checkPermission( node.getPrimaryPath(), Permission.LOCK_MNGMT); // Update the lock timeout info.updateTimeoutTime(); } }
/** * {@inheritDoc} * @throws LockException if this <code>Session</code> is not the lock holder * or if this <code>Lock</code> is not alive. */ public void refresh() throws LockException, RepositoryException { if (!isLive()) { info.throwLockException( "Lock is not live any more", (SessionImpl) node.getSession()); } else if (!isLockOwningSession()) { info.throwLockException( "Session does not hold lock.", (SessionImpl) node.getSession()); } else { // make sure the current session has sufficient privileges to refresh // the lock. SessionImpl session = (SessionImpl) node.getSession(); session.getAccessManager().checkPermission( node.getPrimaryPath(), Permission.LOCK_MNGMT); // Update the lock timeout info.updateTimeoutTime(); } }
session.getAccessManager().checkPermission(path, Permission.VERSION_MNGMT);
session.getAccessManager().checkPermission(path, Permission.VERSION_MNGMT);
sessionContext.getAccessManager().checkPermission( nodePath, Permission.NODE_TYPE_MNGMT);
sessionContext.getAccessManager().checkPermission( nodePath, Permission.NODE_TYPE_MNGMT);