public void checkPermissions(@Nonnull String oakPath, @Nonnull String actions) throws RepositoryException { if (!hasPermissions(oakPath, actions)) { throw new AccessDeniedException("Access denied."); } }
public static Node copy(Node srcNode, Node destNode) { try { Session sess = srcNode.getSession(); return copy(sess, srcNode.getPath(), destNode.getPath()); } catch (AccessDeniedException e) { log.debug("Access denied", e); throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to copy source node: " + srcNode + " to destination node: " + destNode, e); } }
@Nonnull public static Map<String, String> getUserProperties(@Nonnull final Node node) { iterator = node.getProperties(); } catch (AccessDeniedException e) { log.debug("Access denied", e); throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to get properties for node: " + node, e); throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to access property \"" + property + "\" on node: " + node, e);
@Nonnull @Override public Node perform() throws RepositoryException { if (node.isRoot()) { throw new ItemNotFoundException("Root has no parent"); } else { NodeDelegate parent = node.getParent(); if (parent == null) { throw new AccessDeniedException(); } return createNode(parent, sessionContext); } } });
private void cacheGroups(@Nonnull Tree authorizableNode, @Nonnull Set<Group> groupPrincipals) { try { root.refresh(); log.debug("Failed to cache group membership", e.getMessage()); } catch (CommitFailedException e) { log.debug("Failed to cache group membership", e.getMessage(), e);
public RepositoryException asRepositoryException(@Nonnull String message) { if (isConstraintViolation()) { return new ConstraintViolationException(message, this); return new NoSuchNodeTypeException(message, this); } else if (isAccessViolation()) { return new AccessDeniedException(message, this); } else if (isAccessControlViolation()) { return new AccessControlException(message, this); return new UnsupportedRepositoryOperationException(message, this); } else { return new RepositoryException(message, this);
private boolean nonVersionableNodeChckoutCheck(String s) throws RepositoryException { Node vParent = null; try { vParent = session.getNode(s).getParent(); while (!vParent.isNodeType("mix:simpleVersionable")) { vParent = vParent.getParent(); } } catch (ItemNotFoundException e) { // root reached. } catch (AccessDeniedException e) { throw new AccessDeniedException("Access denied on node " + s); } catch (PathNotFoundException e) { throw new PathNotFoundException("No such path exists " + s); } try { if (vParent != null && vParent.isNodeType("mix:simpleVersionable")) { if (vParent.isCheckedOut()) { return true; } else { return false; } } else { return true; } } catch (RepositoryException e) { throw new RepositoryException(e.getMessage()); } }
/** * @see AccessManager#checkPermission(ItemId, int) */ @Deprecated public void checkPermission(ItemId id, int permissions) throws AccessDeniedException, ItemNotFoundException, RepositoryException { log.warn("checkPermission(ItemId, int) is DEPRECATED!", new RepositoryException( "Use of deprecated method checkPermission(ItemId, int)")); // just use the isGranted method if (!isGranted(id, permissions)) { throw new AccessDeniedException(); } }
public void testReadVersionInfo3() throws RepositoryException, NotExecutableException { Node trn = getTestNode(); modifyPrivileges(trn.getPath(), PrivilegeRegistry.REP_WRITE, true); modifyPrivileges(trn.getPath(), Privilege.JCR_NODE_TYPE_MANAGEMENT, true); modifyPrivileges(trn.getPath(), Privilege.JCR_VERSION_MANAGEMENT, true); modifyPrivileges(VERSION_STORAGE_PATH, Privilege.JCR_READ, false); Node n = createVersionableNode(trn); assertTrue(n.isNodeType(mixVersionable)); assertFalse(n.isModified()); try { n.getVersionHistory(); n.getBaseVersion(); fail("No READ permission in the version storage"); } catch (AccessDeniedException e) { // success log.debug(e.getMessage()); } catch (ItemNotFoundException e) { // success log.debug(e.getMessage()); } } }
if (!exists()) { log.warn("Unable to retrieve lock: no item found at '" + getResourcePath() + "'"); } else if (((Node) item).isLocked()) { Lock jcrLock = ((Node) item).getLock(); lock = new JcrActiveLock(jcrLock); DavResourceLocator locator = super.getLocator(); String lockroot = locator .getFactory() .createResourceLocator(locator.getPrefix(), locator.getWorkspacePath(), jcrLock.getNode().getPath(), false).getHref(false); lock.setLockroot(lockroot); log.error("Error while accessing resource lock: "+e.getMessage()); } catch (UnsupportedRepositoryOperationException e) { log.error("Error while accessing resource lock: "+e.getMessage()); } catch (RepositoryException e) { log.error("Error while accessing resource lock: "+e.getMessage());
public static String getPath(Node node) { try { return node.getPath(); } catch (AccessDeniedException e) { log.debug("Access denied", e); throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Unable to get the Path", e); } }
public static Node getNode(Node parentNode, String name) { try { return parentNode.getNode(name); } catch (AccessDeniedException e) { log.debug("Access denied", e); throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to retrieve the Node named " + name, e); } }
public static Node createNode(Node parentNode, String name, String nodeType) { try { return parentNode.addNode(name, nodeType); } catch (AccessDeniedException e) { log.debug("Access denied", e); throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to create the Node named " + name, e); } }
public static <T extends JcrObject> T getReferencedObject(Node node, String property, JcrObjectTypeResolver<T> typeResolver) { try { Property prop = node.getProperty(property); return createJcrObject(prop.getNode(), typeResolver.resolve(prop.getNode())); } catch (AccessDeniedException e) { log.debug("Access denied", e); throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to dereference object of type using: " + typeResolver, e); } }
public static String getName(Node node) { try { return node.getName(); } catch (AccessDeniedException e) { log.debug("Access denied", e); throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Unable to get name of Node " + node, e); } }
public static boolean hasProperty(Node node, String propName) { try { return node.hasProperty(propName); } catch (AccessDeniedException e) { log.debug("Access denied", e); throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to test for property", e); } }
public static boolean hasNode(Node parentNode, String name) { try { return parentNode.hasNode(name); } catch (AccessDeniedException e) { log.debug("Access denied", e); throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to check for the existence of the node named " + name, e); } }
RepositoryException ex) { if (ex instanceof AccessDeniedException) { return new AccessDeniedException(ex.getMessage()); } else if (ex instanceof ConstraintViolationException) { return new ConstraintViolationException(ex.getMessage()); } else if (ex instanceof InvalidItemStateException) { return new InvalidItemStateException(ex.getMessage()); } else if (ex instanceof InvalidQueryException) { return new InvalidQueryException(ex.getMessage()); return new ItemExistsException(ex.getMessage()); } else if (ex instanceof ItemNotFoundException) { return new ItemNotFoundException(ex.getMessage()); } else if (ex instanceof LockException) { return new LockException(ex.getMessage());
@Override public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { boolean success; try { success = collect(); } catch (AccessDeniedException e) { // don't throw further, simply return error and break filter chain log.debug(e.getMessage(), e); if (!response.isCommitted()) { response.setStatus(HttpServletResponse.SC_FORBIDDEN); } // stop the chain return; } catch (RepositoryException e) { log.error(e.getMessage(), e); throw new ServletException(e.getMessage(), e); } if (!success) { log.debug("Resource not found, redirecting request for [{}] to 404 URI", request.getRequestURI()); if (!response.isCommitted()) { response.sendError(HttpServletResponse.SC_NOT_FOUND); } else { log.info("Unable to redirect to 404 page, response is already committed. URI was {}", request.getRequestURI()); } // stop the chain return; } chain.doFilter(request, response); }
state = sism.getItemState(itemId); } catch (NoSuchItemStateException nsise) { throw new ItemNotFoundException(itemId.toString(), nsise); } catch (ItemStateException ise) { String msg = "failed to retrieve item state of item " + itemId; log.error(msg, ise); throw new RepositoryException(msg, ise); throw new AccessDeniedException("cannot read item " + data.getId());