jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1411607 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: security/user/UserConfigurationImpl.java security/user/UserContext.java spi/security/Context.java spi/security/SecurityConfiguration.java
Date Tue, 20 Nov 2012 10:11:37 GMT
Author: angela
Date: Tue Nov 20 10:11:36 2012
New Revision: 1411607

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

- detection of user-items should be defined by user-mgt implementation

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserContext.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/Context.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserConfigurationImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/SecurityConfiguration.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserConfigurationImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserConfigurationImpl.java?rev=1411607&r1=1411606&r2=1411607&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserConfigurationImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserConfigurationImpl.java
Tue Nov 20 10:11:36 2012
@@ -27,6 +27,7 @@ import org.apache.jackrabbit.oak.namepat
 import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
 import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer;
 import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
+import org.apache.jackrabbit.oak.spi.security.Context;
 import org.apache.jackrabbit.oak.spi.security.SecurityConfiguration;
 import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
 import org.apache.jackrabbit.oak.spi.security.user.UserConfiguration;
@@ -61,6 +62,7 @@ public class UserConfigurationImpl exten
         return new UserInitializer(securityProvider);
     }
 
+    @Nonnull
     @Override
     public List<ValidatorProvider> getValidatorProviders() {
         ValidatorProvider vp = new UserValidatorProvider(getConfigurationParameters());
@@ -73,6 +75,12 @@ public class UserConfigurationImpl exten
         return Collections.<ProtectedItemImporter>singletonList(new UserImporter(config));
     }
 
+    @Nonnull
+    @Override
+    public Context getContext() {
+        return new UserContext();
+    }
+
     //--------------------------------------------------< UserConfiguration >---
     @Nonnull
     @Override

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserContext.java?rev=1411607&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserContext.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserContext.java
Tue Nov 20 10:11:36 2012
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.security.user;
+
+import org.apache.jackrabbit.JcrConstants;
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.spi.security.Context;
+import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
+import org.apache.jackrabbit.oak.util.NodeUtil;
+
+/**
+ * UserContext... TODO
+ */
+class UserContext implements Context {
+
+    //------------------------------------------------------------< Context >---
+    @Override
+    public boolean definesProperty(Tree parent, PropertyState property) {
+        NodeUtil node = new NodeUtil(parent);
+        String ntName = node.getName(JcrConstants.JCR_PRIMARYTYPE);
+        if (UserConstants.NT_REP_USER.equals(ntName)) {
+            return UserConstants.USER_PROPERTY_NAMES.contains(property.getName());
+        } else if (UserConstants.NT_REP_GROUP.equals(ntName)) {
+            return UserConstants.GROUP_PROPERTY_NAMES.contains(property.getName());
+        } else if (UserConstants.NT_REP_MEMBERS.equals(ntName)) {
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public boolean definesTree(Tree tree) {
+        NodeUtil node = new NodeUtil(tree);
+        String ntName = node.getName(JcrConstants.JCR_PRIMARYTYPE);
+        return UserConstants.NT_REP_GROUP.equals(ntName) || UserConstants.NT_REP_USER.equals(ntName)
|| UserConstants.NT_REP_MEMBERS.equals(ntName);
+    }
+
+    @Override
+    public boolean definesItems(String path) {
+        // TODO
+        return false;
+    }
+}
\ No newline at end of file

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/Context.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/Context.java?rev=1411607&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/Context.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/Context.java
Tue Nov 20 10:11:36 2012
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.spi.security;
+
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Tree;
+
+/**
+ * Context... TODO
+ */
+public interface Context {
+
+    boolean definesProperty(Tree parent, PropertyState property);
+
+    boolean definesTree(Tree tree);
+
+    boolean definesItems(String path);
+}
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/SecurityConfiguration.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/SecurityConfiguration.java?rev=1411607&r1=1411606&r2=1411607&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/SecurityConfiguration.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/SecurityConfiguration.java
Tue Nov 20 10:11:36 2012
@@ -20,6 +20,8 @@ import java.util.Collections;
 import java.util.List;
 import javax.annotation.Nonnull;
 
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.spi.commit.Observer;
 import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
 import org.apache.jackrabbit.oak.spi.lifecycle.CompositeInitializer;
@@ -46,6 +48,9 @@ public interface SecurityConfiguration {
     @Nonnull
     List<ProtectedItemImporter> getProtectedItemImporters();
 
+    @Nonnull
+    Context getContext();
+
     /**
      * Default implementation that provides empty validators/parameters.
      */
@@ -80,6 +85,26 @@ public interface SecurityConfiguration {
         public List<ProtectedItemImporter> getProtectedItemImporters() {
             return Collections.emptyList();
         }
+
+        @Override
+        public Context getContext() {
+            return new Context() {
+                @Override
+                public boolean definesProperty(Tree parent, PropertyState property) {
+                    return false;
+                }
+
+                @Override
+                public boolean definesTree(Tree tree) {
+                    return false;
+                }
+
+                @Override
+                public boolean definesItems(String path) {
+                    return false;
+                }
+            };
+        }
     }
 
 }
\ No newline at end of file



Mime
View raw message