Search in sources :

Example 1 with AccessControlEditor

use of org.apache.jackrabbit.core.security.authorization.AccessControlEditor in project jackrabbit by apache.

the class CombinedEditor method removePolicy.

/**
     * @see AccessControlEditor#removePolicy(String,AccessControlPolicy)
     */
public void removePolicy(String nodePath, AccessControlPolicy policy) throws AccessControlException, PathNotFoundException, RepositoryException {
    for (AccessControlEditor editor : editors) {
        try {
            // return as soon as the first editor successfully handled the
            // specified template
            editor.removePolicy(nodePath, policy);
            log.debug("Removed template " + policy + " using " + editor);
            return;
        } catch (AccessControlException e) {
            log.debug(e.getMessage());
        // ignore and try next
        }
    }
    // neither of the editors was able to remove a policy at nodePath
    throw new AccessControlException("Unable to remove template " + policy);
}
Also used : AccessControlException(javax.jcr.security.AccessControlException) AccessControlEditor(org.apache.jackrabbit.core.security.authorization.AccessControlEditor)

Example 2 with AccessControlEditor

use of org.apache.jackrabbit.core.security.authorization.AccessControlEditor in project jackrabbit by apache.

the class CombinedEditor method setPolicy.

/**
     * @see AccessControlEditor#setPolicy(String,AccessControlPolicy)
     */
public void setPolicy(String nodePath, AccessControlPolicy template) throws AccessControlException, PathNotFoundException, RepositoryException {
    for (AccessControlEditor editor : editors) {
        try {
            // return as soon as the first editor successfully handled the
            // specified template
            editor.setPolicy(nodePath, template);
            log.debug("Set template " + template + " using " + editor);
            return;
        } catch (AccessControlException e) {
            log.debug(e.getMessage());
        // ignore and try next
        }
    }
    // none accepted -> throw
    throw new AccessControlException("None of the editors accepted policy " + template + " at " + nodePath);
}
Also used : AccessControlException(javax.jcr.security.AccessControlException) AccessControlEditor(org.apache.jackrabbit.core.security.authorization.AccessControlEditor)

Example 3 with AccessControlEditor

use of org.apache.jackrabbit.core.security.authorization.AccessControlEditor in project jackrabbit by apache.

the class CombinedProvider method getEditor.

/**
     * @see AccessControlProvider#getEditor(javax.jcr.Session)
     */
public AccessControlEditor getEditor(Session editingSession) {
    checkInitialized();
    List<AccessControlEditor> editors = new ArrayList<AccessControlEditor>();
    for (AccessControlProvider provider : providers) {
        try {
            editors.add(provider.getEditor(editingSession));
        } catch (RepositoryException e) {
            log.debug(e.getMessage());
        // ignore.
        }
    }
    if (!editors.isEmpty()) {
        return new CombinedEditor(editors.toArray(new AccessControlEditor[editors.size()]));
    } else {
        log.debug("None of the derived access control providers supports editing.");
        return null;
    }
}
Also used : ArrayList(java.util.ArrayList) AbstractAccessControlProvider(org.apache.jackrabbit.core.security.authorization.AbstractAccessControlProvider) AccessControlProvider(org.apache.jackrabbit.core.security.authorization.AccessControlProvider) RepositoryException(javax.jcr.RepositoryException) AccessControlEditor(org.apache.jackrabbit.core.security.authorization.AccessControlEditor)

Aggregations

AccessControlEditor (org.apache.jackrabbit.core.security.authorization.AccessControlEditor)3 AccessControlException (javax.jcr.security.AccessControlException)2 ArrayList (java.util.ArrayList)1 RepositoryException (javax.jcr.RepositoryException)1 AbstractAccessControlProvider (org.apache.jackrabbit.core.security.authorization.AbstractAccessControlProvider)1 AccessControlProvider (org.apache.jackrabbit.core.security.authorization.AccessControlProvider)1