jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1522494 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction: CompositeRestrictionProvider.java RestrictionProvider.java
Date Thu, 12 Sep 2013 09:09:28 GMT
Author: angela
Date: Thu Sep 12 09:09:27 2013
New Revision: 1522494

URL: http://svn.apache.org/r1522494
Log:
OAK-51 : Access Control Management

- composite restrictions

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/CompositeRestrictionProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/RestrictionProvider.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/CompositeRestrictionProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/CompositeRestrictionProvider.java?rev=1522494&r1=1522493&r2=1522494&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/CompositeRestrictionProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/CompositeRestrictionProvider.java
Thu Sep 12 09:09:27 2013
@@ -27,6 +27,7 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.security.AccessControlException;
 
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Sets;
 import org.apache.jackrabbit.oak.api.Tree;
 
@@ -38,12 +39,16 @@ public class CompositeRestrictionProvide
 
     private final Collection<? extends RestrictionProvider> providers;
 
-    private CompositeRestrictionProvider(Collection<? extends RestrictionProvider>
providers) {
-        this.providers = providers;
+    private CompositeRestrictionProvider(@Nonnull Collection<? extends RestrictionProvider>
providers) {
+        this.providers = ImmutableSet.copyOf(providers);
     }
 
-    public static RestrictionProvider newInstance(Collection<? extends RestrictionProvider>
providers) {
-        return new CompositeRestrictionProvider(providers);
+    public static RestrictionProvider newInstance(@Nonnull Collection<? extends RestrictionProvider>
providers) {
+        switch (providers.size()) {
+            case 0: return EMPTY;
+            case 1: return providers.iterator().next();
+            default: return new CompositeRestrictionProvider(providers);
+        }
     }
 
     @Nonnull

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/RestrictionProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/RestrictionProvider.java?rev=1522494&r1=1522493&r2=1522494&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/RestrictionProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/RestrictionProvider.java
Thu Sep 12 09:09:27 2013
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.oak.spi.security.authorization.restriction;
 
+import java.util.Collections;
 import java.util.Set;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
@@ -129,4 +130,51 @@ public interface RestrictionProvider {
      */
     @Nonnull
     RestrictionPattern getPattern(@Nullable String oakPath, @Nonnull Tree tree);
+
+    /**
+     * Empty restriction provider implementation that doesn't support any
+     * restrictions.
+     */
+    RestrictionProvider EMPTY = new RestrictionProvider() {
+
+        @Nonnull
+        @Override
+        public Set<RestrictionDefinition> getSupportedRestrictions(@Nullable String
oakPath) {
+            return Collections.emptySet();
+        }
+
+        @Nonnull
+        @Override
+        public Restriction createRestriction(@Nullable String oakPath, @Nonnull String oakName,
@Nonnull Value value) throws AccessControlException, RepositoryException {
+            throw new AccessControlException("This implementation doesn't support any restrictions");
+        }
+
+        @Nonnull
+        @Override
+        public Restriction createRestriction(@Nullable String oakPath, @Nonnull String oakName,
@Nonnull Value... values) throws AccessControlException, RepositoryException {
+            throw new AccessControlException("This implementation doesn't support any restrictions");
+        }
+
+        @Nonnull
+        @Override
+        public Set<Restriction> readRestrictions(@Nullable String oakPath, @Nonnull
Tree aceTree) {
+            return Collections.emptySet();
+        }
+
+        @Override
+        public void writeRestrictions(String oakPath, Tree aceTree, Set<Restriction>
restrictions) {
+            // nothing to do
+        }
+
+        @Override
+        public void validateRestrictions(@Nullable String oakPath, @Nonnull Tree aceTree)
{
+            // nothing to do
+        }
+
+        @Nonnull
+        @Override
+        public RestrictionPattern getPattern(@Nullable String oakPath, @Nonnull Tree tree)
{
+            return RestrictionPattern.EMPTY;
+        }
+    };
 }



Mime
View raw message