jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r736274 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/security/authorization/acl/ main/java/org/apache/jackrabbit/core/security/authorization/principalbased/ main/resources/org/apache/jackrabbit/core/nodet...
Date Wed, 21 Jan 2009 09:57:51 GMT
Author: angela
Date: Wed Jan 21 01:57:49 2009
New Revision: 736274

URL: http://svn.apache.org/viewvc?rev=736274&view=rev
Log:
JCR-1944: Privilege content representation should be of property type NAME

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/ACLEditor.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/principalbased/ACLEditor.java
    jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd
    jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.xml
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/security/AccessControlDiscoveryTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/ACLEditor.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/ACLEditor.java?rev=736274&r1=736273&r2=736274&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/ACLEditor.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/acl/ACLEditor.java
Wed Jan 21 01:57:49 2009
@@ -42,6 +42,8 @@
 import javax.jcr.Session;
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
+import javax.jcr.PropertyType;
+import javax.jcr.ValueFormatException;
 import java.security.Principal;
 
 /**
@@ -301,11 +303,12 @@
      * @param privileges
      * @param valueFactory
      * @return an array of Value.
+     * @throws javax.jcr.ValueFormatException
      */
-    private static Value[] getPrivilegeNames(Privilege[] privileges, ValueFactory valueFactory)
{
+    private static Value[] getPrivilegeNames(Privilege[] privileges, ValueFactory valueFactory)
throws ValueFormatException {
         Value[] names = new Value[privileges.length];
         for (int i = 0; i < privileges.length; i++) {
-            names[i] = valueFactory.createValue(privileges[i].getName());
+            names[i] = valueFactory.createValue(privileges[i].getName(), PropertyType.NAME);
         }
         return names;
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/principalbased/ACLEditor.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/principalbased/ACLEditor.java?rev=736274&r1=736273&r2=736274&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/principalbased/ACLEditor.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/principalbased/ACLEditor.java
Wed Jan 21 01:57:49 2009
@@ -43,6 +43,7 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
+import javax.jcr.PropertyType;
 import java.security.Principal;
 
 /**
@@ -183,7 +184,7 @@
             Privilege[] privs = ace.getPrivileges();
             Value[] vs = new Value[privs.length];
             for (int j = 0; j < privs.length; j++) {
-                vs[j] = vf.createValue(privs[j].getName());
+                vs[j] = vf.createValue(privs[j].getName(), PropertyType.NAME);
             }
             setSecurityProperty(aceNode, P_PRIVILEGES, vs);
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd?rev=736274&r1=736273&r2=736274&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd
Wed Jan 21 01:57:49 2009
@@ -188,7 +188,7 @@
 
 [rep:ACE]
   - rep:principalName (string) protected mandatory
-  - rep:privileges (string) protected mandatory multiple
+  - rep:privileges (name) protected mandatory multiple
   - rep:nodePath (path) protected
   - rep:glob (string) protected
   - * (undefined) protected

Modified: jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.xml?rev=736274&r1=736273&r2=736274&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.xml
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.xml
Wed Jan 21 01:57:49 2009
@@ -429,7 +429,7 @@
             <supertype>nt:base</supertype>
         </supertypes>
         <propertyDefinition name="rep:principalName" requiredType="String" autoCreated="false"
mandatory="true" onParentVersion="COPY" protected="true" multiple="false" />
-        <propertyDefinition name="rep:privileges" requiredType="String" autoCreated="false"
mandatory="true" onParentVersion="COPY" protected="true" multiple="true" />
+        <propertyDefinition name="rep:privileges" requiredType="Name" autoCreated="false"
mandatory="true" onParentVersion="COPY" protected="true" multiple="true" />
         <propertyDefinition name="rep:nodePath" requiredType="Path" autoCreated="false"
mandatory="false" onParentVersion="COPY" protected="true" multiple="false" />
         <propertyDefinition name="rep:glob" requiredType="String" autoCreated="false"
mandatory="false" onParentVersion="COPY" protected="true" multiple="false" />
         <propertyDefinition name="*" requiredType="undefined" autoCreated="false" mandatory="false"
onParentVersion="COPY" protected="true" multiple="false" />

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/security/AccessControlDiscoveryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/security/AccessControlDiscoveryTest.java?rev=736274&r1=736273&r2=736274&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/security/AccessControlDiscoveryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/security/AccessControlDiscoveryTest.java
Wed Jan 21 01:57:49 2009
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.api.jsr283.security;
 
 import org.apache.jackrabbit.test.NotExecutableException;
+import org.apache.jackrabbit.spi.Name;
 
 import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
@@ -138,6 +139,40 @@
     }
 
     /**
+     * Tests if the privilege name is treated as JCR Name and consequently
+     * reflects changes made to the namespace prefix.
+     * 
+     * @throws RepositoryException
+     */
+    public void testPrivilegeName() throws RepositoryException {
+        Privilege allPriv = acMgr.privilegeFromName(Privilege.JCR_ALL);
+        try {
+            String remappedPrefix = "_jcr";
+            superuser.setNamespacePrefix(remappedPrefix, Name.NS_JCR_URI);
+
+            List l = new ArrayList();
+            l.add(acMgr.privilegeFromName(Privilege.JCR_ALL));
+            l.add(acMgr.privilegeFromName(remappedPrefix + ":all"));
+
+            for (Iterator it = l.iterator(); it.hasNext();) {
+                Privilege p = (Privilege) it.next();
+
+                assertEquals("The privilege name must reflect the modified namespace prefix.",remappedPrefix
+ ":all", p.getName());
+                assertEquals("jcr:all privileges must be equal.",allPriv, p);
+            }
+
+            try {
+                acMgr.privilegeFromName("jcr:all");
+                fail("Modified namespace prefix: 'jcr:all' privilege must not exist.");
+            } catch (RepositoryException e) {
+                // success
+            }
+        } finally {
+            superuser.setNamespacePrefix(Name.NS_JCR_PREFIX, Name.NS_JCR_URI);
+        }
+    }
+
+    /**
      *
      * @throws RepositoryException
      */



Mime
View raw message