javax.jcr.AccessDeniedException Java Examples

The following examples show how to use javax.jcr.AccessDeniedException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AdminPermissionCheckerTest.java    From jackrabbit-filevault with Apache License 2.0 6 votes vote down vote up
@Test
public void testAdditionalAdminUser() throws AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
    JackrabbitSession jackrabbitSession = (JackrabbitSession) admin;
    Authorizable vip = jackrabbitSession.getUserManager().getAuthorizable(TEST_USER);
    assertNull("test user must not exist", vip);

    jackrabbitSession.getUserManager().createUser(TEST_USER, TEST_USER);
    admin.save();

    Session session = repository.login(new SimpleCredentials(TEST_USER, TEST_USER.toCharArray()));
    try {
        assertTrue(
                "\"" + TEST_USER + "\" is additional admin/system thus should have admin permissions",
                AdminPermissionChecker.hasAdministrativePermissions(session, TEST_USER));
    } finally {
        session.logout();
    }
}
 
Example #2
Source File: JcrPackageManagerImplTest.java    From jackrabbit-filevault with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetPackageRootNoCreateAccess() throws Exception {
    // TODO: maybe rather change the setup of the test-base to not assume that everyone has full read-access
    AccessControlManager acMgr = admin.getAccessControlManager();
    JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, "/");
    for (AccessControlEntry ace : acl.getAccessControlEntries()) {
        acl.removeAccessControlEntry(ace);
    }
    acl.addEntry(AccessControlUtils.getEveryonePrincipal(admin),
            AccessControlUtils.privilegesFromNames(admin, javax.jcr.security.Privilege.JCR_READ),
            true,
            Collections.singletonMap("rep:glob", admin.getValueFactory().createValue("etc/*")));
    admin.save();

    Session anonymous = repository.login(new GuestCredentials());
    try {
        JcrPackageManagerImpl jcrPackageManager = new JcrPackageManagerImpl(anonymous, new String[0]);
        assertNull(jcrPackageManager.getPackageRoot(true));

        try {
            jcrPackageManager.getPackageRoot(false);
            fail();
        } catch (AccessDeniedException | PathNotFoundException e) {
            // success
        }
    }  finally {
        anonymous.logout();
    }
}
 
Example #3
Source File: NodeImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public void unlock() throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, InvalidItemStateException, RepositoryException {
    throw new UnsupportedRepositoryOperationException();
}
 
Example #4
Source File: ItemWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public void remove() throws VersionException, LockException, ConstraintViolationException, AccessDeniedException, RepositoryException {
    this.sessionWrapper.removeItem(this.getPath());
}
 
Example #5
Source File: AccessControlManagerWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public AccessControlPolicy[] getPolicies(String absPath) throws PathNotFoundException, AccessDeniedException, RepositoryException {
    return delegate.getPolicies(absPath);
}
 
Example #6
Source File: AccessControlManagerWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public AccessControlPolicy[] getEffectivePolicies(String absPath) throws PathNotFoundException, AccessDeniedException, RepositoryException {
    return delegate.getEffectivePolicies(absPath);
}
 
Example #7
Source File: AccessControlManagerWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public AccessControlPolicyIterator getApplicablePolicies(String absPath) throws PathNotFoundException, AccessDeniedException, RepositoryException {
    return delegate.getApplicablePolicies(absPath);
}
 
Example #8
Source File: AccessControlManagerWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public void setPolicy(String absPath, AccessControlPolicy policy) throws PathNotFoundException, AccessControlException, AccessDeniedException, LockException, VersionException, RepositoryException {
    delegate.setPolicy(absPath, policy);
}
 
Example #9
Source File: AccessControlManagerWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public void removePolicy(String absPath, AccessControlPolicy policy) throws PathNotFoundException, AccessControlException, AccessDeniedException, LockException, VersionException, RepositoryException {
    delegate.removePolicy(absPath, policy);
}
 
Example #10
Source File: SessionWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public void removeItem(String absPath) throws VersionException, LockException, ConstraintViolationException, AccessDeniedException, RepositoryException {
    this.wrappedSession.removeItem(absPath);
}
 
Example #11
Source File: SessionWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public void save() throws AccessDeniedException, ItemExistsException, ReferentialIntegrityException, ConstraintViolationException, InvalidItemStateException, VersionException, LockException, NoSuchNodeTypeException, RepositoryException {
    this.wrappedSession.save();
}
 
Example #12
Source File: NodeImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public void update(String srcWorkspace) throws NoSuchWorkspaceException, AccessDeniedException, LockException, InvalidItemStateException, RepositoryException {
    //Not Implemented
}
 
Example #13
Source File: NodeImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public NodeIterator merge(String srcWorkspace, boolean bestEffort) throws NoSuchWorkspaceException, AccessDeniedException, MergeException, LockException, InvalidItemStateException, RepositoryException {
    return null;  //deprecated
}
 
Example #14
Source File: NodeImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public String getCorrespondingNodePath(String workspaceName) throws ItemNotFoundException, NoSuchWorkspaceException, AccessDeniedException, RepositoryException {
    return null;  //Not Implemented
}
 
Example #15
Source File: NodeImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public Lock lock(boolean isDeep, boolean isSessionScoped) throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, InvalidItemStateException, RepositoryException {
    throw new UnsupportedRepositoryOperationException();
}
 
Example #16
Source File: NodeImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public Lock getLock() throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, RepositoryException {
    throw new UnsupportedRepositoryOperationException();
}
 
Example #17
Source File: ItemWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public void save() throws AccessDeniedException, ItemExistsException, ConstraintViolationException, InvalidItemStateException, ReferentialIntegrityException, VersionException, LockException, NoSuchNodeTypeException, RepositoryException {
    this.sessionWrapper.save();
}
 
Example #18
Source File: WorkspaceImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public void copy(String srcAbsPath, String destAbsPath) throws ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
}
 
Example #19
Source File: WorkspaceImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public void copy(String srcWorkspace, String srcAbsPath, String destAbsPath) throws NoSuchWorkspaceException, ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
}
 
Example #20
Source File: WorkspaceImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public void clone(String srcWorkspace, String srcAbsPath, String destAbsPath, boolean removeExisting) throws NoSuchWorkspaceException, ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
}
 
Example #21
Source File: WorkspaceImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public void move(String srcAbsPath, String destAbsPath) throws ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
}
 
Example #22
Source File: WorkspaceImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior) throws PathNotFoundException, ConstraintViolationException, VersionException, LockException, AccessDeniedException, RepositoryException {
    return null;
}
 
Example #23
Source File: WorkspaceImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public void importXML(String parentAbsPath, InputStream in, int uuidBehavior) throws IOException, VersionException, PathNotFoundException, ItemExistsException, ConstraintViolationException, InvalidSerializedDataException, LockException, AccessDeniedException, RepositoryException {
}
 
Example #24
Source File: WorkspaceImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public void createWorkspace(String name) throws AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
}
 
Example #25
Source File: WorkspaceImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public void createWorkspace(String name, String srcWorkspace) throws AccessDeniedException, UnsupportedRepositoryOperationException, NoSuchWorkspaceException, RepositoryException {
}
 
Example #26
Source File: WorkspaceImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public void deleteWorkspace(String name) throws AccessDeniedException, UnsupportedRepositoryOperationException, NoSuchWorkspaceException, RepositoryException {
}
 
Example #27
Source File: ItemImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public void remove() throws VersionException, LockException, ConstraintViolationException, AccessDeniedException, RepositoryException {
    session.removeItem(this);
}
 
Example #28
Source File: SessionFactoryUtils.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Jcr exception translator - it converts specific JSR-170 checked exceptions into unchecked Spring DA
 * exception.
 * @author Guillaume Bort <[email protected]>
 * @author Costin Leau
 * @author Sergio Bossa
 * @author Salvatore Incandela
 * @param ex
 * @return
 */
public static DataAccessException translateException(RepositoryException ex) {
    if (ex instanceof AccessDeniedException) {
        return new DataRetrievalFailureException("Access denied to this data", ex);
    }
    if (ex instanceof ConstraintViolationException) {
        return new DataIntegrityViolationException("Constraint has been violated", ex);
    }
    if (ex instanceof InvalidItemStateException) {
        return new ConcurrencyFailureException("Invalid item state", ex);
    }
    if (ex instanceof InvalidQueryException) {
        return new DataRetrievalFailureException("Invalid query", ex);
    }
    if (ex instanceof InvalidSerializedDataException) {
        return new DataRetrievalFailureException("Invalid serialized data", ex);
    }
    if (ex instanceof ItemExistsException) {
        return new DataIntegrityViolationException("An item already exists", ex);
    }
    if (ex instanceof ItemNotFoundException) {
        return new DataRetrievalFailureException("Item not found", ex);
    }
    if (ex instanceof LoginException) {
        return new DataAccessResourceFailureException("Bad login", ex);
    }
    if (ex instanceof LockException) {
        return new ConcurrencyFailureException("Item is locked", ex);
    }
    if (ex instanceof MergeException) {
        return new DataIntegrityViolationException("Merge failed", ex);
    }
    if (ex instanceof NamespaceException) {
        return new InvalidDataAccessApiUsageException("Namespace not registred", ex);
    }
    if (ex instanceof NoSuchNodeTypeException) {
        return new InvalidDataAccessApiUsageException("No such node type", ex);
    }
    if (ex instanceof NoSuchWorkspaceException) {
        return new DataAccessResourceFailureException("Workspace not found", ex);
    }
    if (ex instanceof PathNotFoundException) {
        return new DataRetrievalFailureException("Path not found", ex);
    }
    if (ex instanceof ReferentialIntegrityException) {
        return new DataIntegrityViolationException("Referential integrity violated", ex);
    }
    if (ex instanceof UnsupportedRepositoryOperationException) {
        return new InvalidDataAccessApiUsageException("Unsupported operation", ex);
    }
    if (ex instanceof ValueFormatException) {
        return new InvalidDataAccessApiUsageException("Incorrect value format", ex);
    }
    if (ex instanceof VersionException) {
        return new DataIntegrityViolationException("Invalid version graph operation", ex);
    }
    // fallback
    return new JcrSystemException(ex);
}
 
Example #29
Source File: WorkspaceWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public void move(String srcAbsPath, String destAbsPath) throws ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
    delegate.move(srcAbsPath, destAbsPath);
}
 
Example #30
Source File: JackrabbitAccessControlManagerWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public JackrabbitAccessControlPolicy[] getPolicies(Principal principal) throws AccessDeniedException, AccessControlException, UnsupportedRepositoryOperationException, RepositoryException {
    return delegate.getPolicies(principal);
}