Return-Path: X-Original-To: apmail-jackrabbit-commits-archive@www.apache.org Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 862D3CB13 for ; Mon, 2 Jul 2012 14:29:42 +0000 (UTC) Received: (qmail 96203 invoked by uid 500); 2 Jul 2012 14:29:42 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 96092 invoked by uid 500); 2 Jul 2012 14:29:41 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 96072 invoked by uid 99); 2 Jul 2012 14:29:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Jul 2012 14:29:41 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Jul 2012 14:29:35 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id C00B6238890B; Mon, 2 Jul 2012 14:29:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1356255 - in /jackrabbit/branches/2.4: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/ Date: Mon, 02 Jul 2012 14:29:12 -0000 To: commits@jackrabbit.apache.org From: reschke@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120702142914.C00B6238890B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: reschke Date: Mon Jul 2 14:29:10 2012 New Revision: 1356255 URL: http://svn.apache.org/viewvc?rev=1356255&view=rev Log: JCR-3352 : Minor improvements for collecting ACEs (ported to 2.4) Modified: jackrabbit/branches/2.4/ (props changed) jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/ACLProvider.java jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/ACLTemplate.java jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/EntryCollector.java Propchange: jackrabbit/branches/2.4/ ------------------------------------------------------------------------------ Merged /jackrabbit/trunk:r1353920 Modified: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?rev=1356255&r1=1356254&r2=1356255&view=diff ============================================================================== --- jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java (original) +++ jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java Mon Jul 2 14:29:10 2012 @@ -595,8 +595,7 @@ public class NodeImpl extends ItemImpl i protected void removeChildNode(NodeId childId) throws RepositoryException { // modify the state of 'this', i.e. the parent node NodeState thisState = (NodeState) getOrCreateTransientItemState(); - ChildNodeEntry entry = - thisState.getChildNodeEntry(childId); + ChildNodeEntry entry = thisState.getChildNodeEntry(childId); if (entry == null) { String msg = "failed to remove child " + childId + " of " + this; log.debug(msg); @@ -923,9 +922,6 @@ public class NodeImpl extends ItemImpl i * otherwise false */ public boolean isNodeType(Name ntName) throws RepositoryException { - // check state of this instance - sanityCheck(); - // first do trivial checks without using type hierarchy Name primary = data.getNodeState().getNodeTypeName(); if (ntName.equals(primary)) { @@ -1360,6 +1356,33 @@ public class NodeImpl extends ItemImpl i } /** + * Returns the name of the primary node type as exposed on the node state + * without retrieving the node type. + * + * @return the name of the primary node type. + */ + public Name getPrimaryNodeTypeName() { + return data.getNodeState().getNodeTypeName(); + } + + /** + * Test if the given node is access controlled. The node is access + * controlled if it is of node type + * {@link org.apache.jackrabbit.core.security.authorization.AccessControlConstants#NT_REP_ACCESS_CONTROLLABLE "rep:AccessControllable"} + * and if it has a child node named + * {@link org.apache.jackrabbit.core.security.authorization.AccessControlConstants#N_POLICY}. + * + * @param node the node to be tested + * @return true if the node is access controlled and has a + * rep:policy child; false otherwise. + * @throws RepositoryException if an error occurs + */ + public boolean isAccessControllable() throws RepositoryException { + return data.getNodeState().hasChildNodeEntry(NameConstants.REP_POLICY, 1) + && isNodeType(NameConstants.REP_ACCESS_CONTROLLABLE); + } + + /** * Same as {@link Node#orderBefore(String, String)} except that * this method takes a Path.Element arguments instead of * Strings. @@ -2268,6 +2291,9 @@ public class NodeImpl extends ItemImpl i * {@inheritDoc} */ public boolean isNodeType(String nodeTypeName) throws RepositoryException { + // check state of this instance + sanityCheck(); + try { return isNodeType(sessionContext.getQName(nodeTypeName)); } catch (NameException e) { Modified: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/ACLProvider.java URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/ACLProvider.java?rev=1356255&r1=1356254&r2=1356255&view=diff ============================================================================== --- jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/ACLProvider.java (original) +++ jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/ACLProvider.java Mon Jul 2 14:29:10 2012 @@ -354,19 +354,15 @@ public class ACLProvider extends Abstrac } /** - * Test if the given node is access controlled. The node is access - * controlled if it is of node type - * {@link AccessControlConstants#NT_REP_ACCESS_CONTROLLABLE "rep:AccessControllable"} - * and if it has a child node named - * {@link AccessControlConstants#N_POLICY}. + * Test if the given node is access controlled. * * @param node the node to be tested - * @return true if the node is access controlled and has a - * rep:policy child; false otherwise. + * @return true if the node is access controlled. * @throws RepositoryException if an error occurs + * @see org.apache.jackrabbit.core.NodeImpl#isAccessControllable() */ static boolean isAccessControlled(NodeImpl node) throws RepositoryException { - return node.hasNode(N_POLICY) && node.isNodeType(NT_REP_ACCESS_CONTROLLABLE); + return node.isAccessControllable(); } Modified: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/ACLTemplate.java URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/ACLTemplate.java?rev=1356255&r1=1356254&r2=1356255&view=diff ============================================================================== --- jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/ACLTemplate.java (original) +++ jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/ACLTemplate.java Mon Jul 2 14:29:10 2012 @@ -21,7 +21,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.Set; import javax.jcr.NamespaceException; import javax.jcr.NodeIterator; @@ -31,7 +30,6 @@ import javax.jcr.Value; import javax.jcr.ValueFactory; import javax.jcr.security.AccessControlEntry; import javax.jcr.security.AccessControlException; -import javax.jcr.security.AccessControlManager; import javax.jcr.security.Privilege; import org.apache.jackrabbit.api.JackrabbitWorkspace; @@ -41,7 +39,6 @@ import org.apache.jackrabbit.api.securit import org.apache.jackrabbit.core.NodeImpl; import org.apache.jackrabbit.core.SessionImpl; import org.apache.jackrabbit.core.id.NodeId; -import org.apache.jackrabbit.core.nodetype.NodeTypeImpl; import org.apache.jackrabbit.core.security.authorization.AbstractACLTemplate; import org.apache.jackrabbit.core.security.authorization.AccessControlEntryImpl; import org.apache.jackrabbit.core.security.authorization.PrivilegeBits; @@ -145,7 +142,7 @@ class ACLTemplate extends AbstractACLTem */ ACLTemplate(NodeImpl aclNode, String path) throws RepositoryException { super(path, (aclNode != null) ? aclNode.getSession().getValueFactory() : null); - if (aclNode == null || !NT_REP_ACL.equals(((NodeTypeImpl)aclNode.getPrimaryNodeType()).getQName())) { + if (aclNode == null || !NT_REP_ACL.equals(aclNode.getPrimaryNodeTypeName())) { throw new IllegalArgumentException("Node must be of type 'rep:ACL'"); } SessionImpl sImpl = (SessionImpl) aclNode.getSession(); @@ -179,9 +176,8 @@ class ACLTemplate extends AbstractACLTem restrictions = Collections.singletonMap(jcrRepGlob, aceNode.getProperty(P_GLOB).getValue()); } // create a new ACEImpl (omitting validation check) - Entry ace = new Entry(princ, privilegeMgr.getBits(privNames), - NT_REP_GRANT_ACE.equals(((NodeTypeImpl) aceNode.getPrimaryNodeType()).getQName()), - restrictions); + boolean isAllow = NT_REP_GRANT_ACE.equals(aceNode.getPrimaryNodeTypeName()); + Entry ace = new Entry(princ, privilegeMgr.getBits(privNames), isAllow, restrictions); // add the entry omitting any validation. entries.add(ace); } catch (RepositoryException e) { Modified: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/EntryCollector.java URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/EntryCollector.java?rev=1356255&r1=1356254&r2=1356255&view=diff ============================================================================== --- jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/EntryCollector.java (original) +++ jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/EntryCollector.java Mon Jul 2 14:29:10 2012 @@ -139,7 +139,7 @@ public class EntryCollector extends Acce NodeImpl root = (NodeImpl) systemSession.getRootNode(); if (ACLProvider.isRepoAccessControlled(root)) { NodeImpl aclNode = root.getNode(N_REPO_POLICY); - filterEntries(filter, new ACLTemplate(aclNode).getEntries(), userAces, groupAces); + filterEntries(filter, new ACLTemplate(aclNode, null).getEntries(), userAces, groupAces); } } else { filterEntries(filter, getEntries(node).getACEs(), userAces, groupAces); @@ -189,7 +189,7 @@ public class EntryCollector extends Acce if (ACLProvider.isAccessControlled(node)) { // collect the aces of that node. NodeImpl aclNode = node.getNode(N_POLICY); - aces = new ACLTemplate(aclNode).getEntries(); + aces = new ACLTemplate(aclNode, node.getPath()).getEntries(); } else { // not access controlled aces = Collections.emptyList();