jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1431504 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization: AccessControlValidator.java PermissionValidator.java
Date Thu, 10 Jan 2013 17:07:01 GMT
Author: angela
Date: Thu Jan 10 17:07:00 2013
New Revision: 1431504

URL: http://svn.apache.org/viewvc?rev=1431504&view=rev
Log:
OAK-51 : Implement JCR Access Control Management (WIP)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidator.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/PermissionValidator.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidator.java?rev=1431504&r1=1431503&r2=1431504&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidator.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidator.java
Thu Jan 10 17:07:00 2013
@@ -27,6 +27,8 @@ import org.apache.jackrabbit.oak.spi.sec
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.util.NodeUtil;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 /**
  * AccessControlValidator... TODO
  */
@@ -69,6 +71,8 @@ class AccessControlValidator implements 
     @Override
     public Validator childNodeAdded(String name, NodeState after) throws CommitFailedException
{
         NodeUtil node = parentAfter.getChild(name);
+        checkNotNull(node);
+
         if (isAccessControlEntry(node)) {
             checkValidAccessControlEntry(node);
             return null;
@@ -81,6 +85,9 @@ class AccessControlValidator implements 
     public Validator childNodeChanged(String name, NodeState before, NodeState after) throws
CommitFailedException {
         NodeUtil nodeBefore = parentBefore.getChild(name);
         NodeUtil nodeAfter = parentAfter.getChild(name);
+        checkNotNull(nodeBefore);
+        checkNotNull(nodeAfter);
+
         if (isAccessControlEntry(nodeAfter)) {
             checkValidAccessControlEntry(nodeAfter);
             return null;
@@ -122,8 +129,8 @@ class AccessControlValidator implements 
             fail("Missing privileges.");
         }
         for (String privilegeName : privilegeNames) {
-            if (!privilegeDefinitions.containsKey(privilegeName)) {
-                fail("Unknown privilege " + privilegeName);
+            if (privilegeName == null || !privilegeDefinitions.containsKey(privilegeName))
{
+                fail("Invalid privilege " + privilegeName);
             }
 
             PrivilegeDefinition def = privilegeDefinitions.get(privilegeName);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/PermissionValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/PermissionValidator.java?rev=1431504&r1=1431503&r2=1431504&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/PermissionValidator.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/PermissionValidator.java
Thu Jan 10 17:07:00 2013
@@ -32,6 +32,8 @@ import org.apache.jackrabbit.oak.util.No
 import org.apache.jackrabbit.oak.version.VersionConstants;
 import org.apache.jackrabbit.util.Text;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 /**
  * PermissionValidator... TODO
  */
@@ -133,6 +135,8 @@ class PermissionValidator implements Val
     }
 
     private Validator checkPermissions(NodeUtil node, boolean isBefore, int defaultPermission)
throws CommitFailedException {
+        checkNotNull(node);
+
         Tree tree = node.getTree();
         String path = tree.getPath();
         int permission;



Mime
View raw message