You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by my...@apache.org on 2014/09/14 12:02:54 UTC
svn commit: r1624823 - in /sling/trunk/bundles/resourceaccesssecurity:
core/src/main/java/org/apache/sling/resourceaccesssecurity/impl/
it/src/main/java/org/apache/sling/resourceaccesssecurity/it/impl/gates/
it/src/test/java/org/apache/sling/resourceac...
Author: mykee
Date: Sun Sep 14 10:02:54 2014
New Revision: 1624823
URL: http://svn.apache.org/r1624823
Log:
SLING-3930 - Service rankings from ResourceAccessGates are not properly handled
Added:
sling/trunk/bundles/resourceaccesssecurity/it/src/main/java/org/apache/sling/resourceaccesssecurity/it/impl/gates/ApplicationGate1Ranking100.java
sling/trunk/bundles/resourceaccesssecurity/it/src/main/java/org/apache/sling/resourceaccesssecurity/it/impl/gates/ApplicationGate1Ranking1000.java
sling/trunk/bundles/resourceaccesssecurity/it/src/main/java/org/apache/sling/resourceaccesssecurity/it/impl/gates/FinalAppGate1Ranking100.java
sling/trunk/bundles/resourceaccesssecurity/it/src/main/java/org/apache/sling/resourceaccesssecurity/it/impl/gates/FinalAppGate1Ranking1000.java
Modified:
sling/trunk/bundles/resourceaccesssecurity/core/src/main/java/org/apache/sling/resourceaccesssecurity/impl/ResourceAccessGateHandler.java
sling/trunk/bundles/resourceaccesssecurity/it/src/test/java/org/apache/sling/resourceaccesssecurity/it/UnsecuredProviderResourceAccessSecurityTest.java
Modified: sling/trunk/bundles/resourceaccesssecurity/core/src/main/java/org/apache/sling/resourceaccesssecurity/impl/ResourceAccessGateHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceaccesssecurity/core/src/main/java/org/apache/sling/resourceaccesssecurity/impl/ResourceAccessGateHandler.java?rev=1624823&r1=1624822&r2=1624823&view=diff
==============================================================================
--- sling/trunk/bundles/resourceaccesssecurity/core/src/main/java/org/apache/sling/resourceaccesssecurity/impl/ResourceAccessGateHandler.java (original)
+++ sling/trunk/bundles/resourceaccesssecurity/core/src/main/java/org/apache/sling/resourceaccesssecurity/impl/ResourceAccessGateHandler.java Sun Sep 14 10:02:54 2014
@@ -110,7 +110,8 @@ public class ResourceAccessGateHandler i
@Override
public int compareTo(final ResourceAccessGateHandler o) {
- return this.reference.compareTo(o.reference);
+ // services with higher service ranking should be the first in a list
+ return -this.reference.compareTo(o.reference);
}
@Override
Added: sling/trunk/bundles/resourceaccesssecurity/it/src/main/java/org/apache/sling/resourceaccesssecurity/it/impl/gates/ApplicationGate1Ranking100.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceaccesssecurity/it/src/main/java/org/apache/sling/resourceaccesssecurity/it/impl/gates/ApplicationGate1Ranking100.java?rev=1624823&view=auto
==============================================================================
--- sling/trunk/bundles/resourceaccesssecurity/it/src/main/java/org/apache/sling/resourceaccesssecurity/it/impl/gates/ApplicationGate1Ranking100.java (added)
+++ sling/trunk/bundles/resourceaccesssecurity/it/src/main/java/org/apache/sling/resourceaccesssecurity/it/impl/gates/ApplicationGate1Ranking100.java Sun Sep 14 10:02:54 2014
@@ -0,0 +1,28 @@
+package org.apache.sling.resourceaccesssecurity.it.impl.gates;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.resourceaccesssecurity.ResourceAccessGate;
+import org.osgi.framework.Constants;
+
+@Component
+@Service(value=ResourceAccessGate.class)
+@Properties({
+ @Property(name=ResourceAccessGate.PATH, label="Path", value="/test/(un|)secured-provider/read(-update|)/(app|mixed)/.*",
+ description="The path is a regular expression for which resources the service should be called"),
+ @Property(name=ResourceAccessGate.OPERATIONS, value="read,update"),
+ @Property(name=ResourceAccessGate.CONTEXT, value=ResourceAccessGate.APPLICATION_CONTEXT),
+ @Property(name = Constants.SERVICE_RANKING, intValue = 100, propertyPrivate = false)
+})
+public class ApplicationGate1Ranking100 extends AResourceAccessGate {
+
+ public static String GATE_ID = "appgate1ranking100";
+
+ @Override
+ protected String getGateId() {
+ return GATE_ID;
+ }
+
+}
Added: sling/trunk/bundles/resourceaccesssecurity/it/src/main/java/org/apache/sling/resourceaccesssecurity/it/impl/gates/ApplicationGate1Ranking1000.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceaccesssecurity/it/src/main/java/org/apache/sling/resourceaccesssecurity/it/impl/gates/ApplicationGate1Ranking1000.java?rev=1624823&view=auto
==============================================================================
--- sling/trunk/bundles/resourceaccesssecurity/it/src/main/java/org/apache/sling/resourceaccesssecurity/it/impl/gates/ApplicationGate1Ranking1000.java (added)
+++ sling/trunk/bundles/resourceaccesssecurity/it/src/main/java/org/apache/sling/resourceaccesssecurity/it/impl/gates/ApplicationGate1Ranking1000.java Sun Sep 14 10:02:54 2014
@@ -0,0 +1,28 @@
+package org.apache.sling.resourceaccesssecurity.it.impl.gates;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.resourceaccesssecurity.ResourceAccessGate;
+import org.osgi.framework.Constants;
+
+@Component
+@Service(value=ResourceAccessGate.class)
+@Properties({
+ @Property(name=ResourceAccessGate.PATH, label="Path", value="/test/(un|)secured-provider/read(-update|)/(app|mixed)/.*",
+ description="The path is a regular expression for which resources the service should be called"),
+ @Property(name=ResourceAccessGate.OPERATIONS, value="read,update"),
+ @Property(name=ResourceAccessGate.CONTEXT, value=ResourceAccessGate.APPLICATION_CONTEXT),
+ @Property(name = Constants.SERVICE_RANKING, intValue = 1000, propertyPrivate = false)
+})
+public class ApplicationGate1Ranking1000 extends AResourceAccessGate {
+
+ public static String GATE_ID = "appgate1ranking1000";
+
+ @Override
+ protected String getGateId() {
+ return GATE_ID;
+ }
+
+}
Added: sling/trunk/bundles/resourceaccesssecurity/it/src/main/java/org/apache/sling/resourceaccesssecurity/it/impl/gates/FinalAppGate1Ranking100.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceaccesssecurity/it/src/main/java/org/apache/sling/resourceaccesssecurity/it/impl/gates/FinalAppGate1Ranking100.java?rev=1624823&view=auto
==============================================================================
--- sling/trunk/bundles/resourceaccesssecurity/it/src/main/java/org/apache/sling/resourceaccesssecurity/it/impl/gates/FinalAppGate1Ranking100.java (added)
+++ sling/trunk/bundles/resourceaccesssecurity/it/src/main/java/org/apache/sling/resourceaccesssecurity/it/impl/gates/FinalAppGate1Ranking100.java Sun Sep 14 10:02:54 2014
@@ -0,0 +1,28 @@
+package org.apache.sling.resourceaccesssecurity.it.impl.gates;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.resourceaccesssecurity.ResourceAccessGate;
+import org.osgi.framework.Constants;
+
+@Component
+@Service(value=ResourceAccessGate.class)
+@Properties({
+ @Property(name=ResourceAccessGate.PATH, label="Path", value="/test/(un|)secured-provider/read(-update|)/(app|mixed)/.*",
+ description="The path is a regular expression for which resources the service should be called"),
+ @Property(name=ResourceAccessGate.FINALOPERATIONS, value="read,update"),
+ @Property(name=ResourceAccessGate.CONTEXT, value=ResourceAccessGate.APPLICATION_CONTEXT),
+ @Property(name = Constants.SERVICE_RANKING, intValue = 100, propertyPrivate = false)
+})
+public class FinalAppGate1Ranking100 extends AResourceAccessGate {
+
+ public static String GATE_ID = "finalappgate1ranking100";
+
+ @Override
+ protected String getGateId() {
+ return GATE_ID;
+ }
+
+}
Added: sling/trunk/bundles/resourceaccesssecurity/it/src/main/java/org/apache/sling/resourceaccesssecurity/it/impl/gates/FinalAppGate1Ranking1000.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceaccesssecurity/it/src/main/java/org/apache/sling/resourceaccesssecurity/it/impl/gates/FinalAppGate1Ranking1000.java?rev=1624823&view=auto
==============================================================================
--- sling/trunk/bundles/resourceaccesssecurity/it/src/main/java/org/apache/sling/resourceaccesssecurity/it/impl/gates/FinalAppGate1Ranking1000.java (added)
+++ sling/trunk/bundles/resourceaccesssecurity/it/src/main/java/org/apache/sling/resourceaccesssecurity/it/impl/gates/FinalAppGate1Ranking1000.java Sun Sep 14 10:02:54 2014
@@ -0,0 +1,28 @@
+package org.apache.sling.resourceaccesssecurity.it.impl.gates;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.resourceaccesssecurity.ResourceAccessGate;
+import org.osgi.framework.Constants;
+
+@Component
+@Service(value=ResourceAccessGate.class)
+@Properties({
+ @Property(name=ResourceAccessGate.PATH, label="Path", value="/test/(un|)secured-provider/read(-update|)/(app|mixed)/.*",
+ description="The path is a regular expression for which resources the service should be called"),
+ @Property(name=ResourceAccessGate.FINALOPERATIONS, value="read,update"),
+ @Property(name=ResourceAccessGate.CONTEXT, value=ResourceAccessGate.APPLICATION_CONTEXT),
+ @Property(name = Constants.SERVICE_RANKING, intValue = 1000, propertyPrivate = false)
+})
+public class FinalAppGate1Ranking1000 extends AResourceAccessGate {
+
+ public static String GATE_ID = "finalappgate1ranking1000";
+
+ @Override
+ protected String getGateId() {
+ return GATE_ID;
+ }
+
+}
Modified: sling/trunk/bundles/resourceaccesssecurity/it/src/test/java/org/apache/sling/resourceaccesssecurity/it/UnsecuredProviderResourceAccessSecurityTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceaccesssecurity/it/src/test/java/org/apache/sling/resourceaccesssecurity/it/UnsecuredProviderResourceAccessSecurityTest.java?rev=1624823&r1=1624822&r2=1624823&view=diff
==============================================================================
--- sling/trunk/bundles/resourceaccesssecurity/it/src/test/java/org/apache/sling/resourceaccesssecurity/it/UnsecuredProviderResourceAccessSecurityTest.java (original)
+++ sling/trunk/bundles/resourceaccesssecurity/it/src/test/java/org/apache/sling/resourceaccesssecurity/it/UnsecuredProviderResourceAccessSecurityTest.java Sun Sep 14 10:02:54 2014
@@ -44,4 +44,39 @@ public class UnsecuredProviderResourceAc
testRead(getTestUsername(), getTestPassword(), path, 404);
}
+
+ @Test
+ public void testReadOnlyApplicationAccessGatePresent() throws Exception {
+ String path = "/test/unsecured-provider/read/app/appgate1-allowread/test.json";
+
+ testRead(getTestUsername(), getTestPassword(), path, 200);
+ }
+
+ @Test
+ public void testCantReadOnlyApplicationAccessGatePresent() throws Exception {
+ String path = "/test/unsecured-provider/read/app/appgate1-denyread/test.json";
+
+ testRead(getTestUsername(), getTestPassword(), path, 404);
+ }
+
+ @Test
+ public void testServiceRanking() throws Exception {
+ String path1 = "/test/unsecured-provider/read/app/appgate1-allowread_finalappgate1ranking1000-denyread/test.json";
+ String path2 = "/test/unsecured-provider/read/app/appgate1-allowread_finalappgate1ranking100-denyread/test.json";
+ String path3 = "/test/unsecured-provider/read/app/finalappgate1-allowread_finalappgate1ranking1000-denyread/test.json";
+ String path4 = "/test/unsecured-provider/read/app/appgate1ranking1000-allowread_finalappgate1ranking100-denyread/test.json";
+ String path5 = "/test/unsecured-provider/read/app/appgate1ranking100-allowread_finalappgate1-denyread/test.json";
+ String path6 = "/test/unsecured-provider/read/app/appgate1-allowread_appgate1ranking1000-denyread/test.json";
+ String path7 = "/test/unsecured-provider/read/app/appgate1ranking100-allowread_appgate1ranking1000-denyread/test.json";
+
+ testRead(getTestUsername(), getTestPassword(), path1, 404);
+ testRead(getTestUsername(), getTestPassword(), path2, 404);
+ testRead(getTestUsername(), getTestPassword(), path3, 404);
+ testRead(getTestUsername(), getTestPassword(), path4, 200);
+ testRead(getTestUsername(), getTestPassword(), path5, 200);
+ testRead(getTestUsername(), getTestPassword(), path6, 200);
+ testRead(getTestUsername(), getTestPassword(), path7, 200);
+ }
+
+
}