jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1407114 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/security/user/ test/java/org/apache/jackrabbit/oak/security/user/
Date Thu, 08 Nov 2012 15:11:58 GMT
Author: angela
Date: Thu Nov  8 15:11:58 2012
New Revision: 1407114

URL: http://svn.apache.org/viewvc?rev=1407114&view=rev
Log:
OAK-50 : Implement User Management (WIP)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizableProperties.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/JcrAuthorizableProperties.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/OakAuthorizableProperties.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserValidatorTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizableProperties.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizableProperties.java?rev=1407114&r1=1407113&r2=1407114&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizableProperties.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizableProperties.java
Thu Nov  8 15:11:58 2012
@@ -17,24 +17,100 @@
 package org.apache.jackrabbit.oak.security.user;
 
 import java.util.Iterator;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 
 /**
- * AuthorizableProperty... TODO
+ * Internal interface covering those methods of {link Authorizable} that deal
+ * with reading and writing custom properties defined with user and groups.
  */
 interface AuthorizableProperties {
 
+    /**
+     * Retrieve all property names located at the given relative path underneath
+     * the associated {@code Authorizable} instance.
+     *
+     * @param relPath A relative path referring to a node associated with a
+     * given authorizable. A relative path consisting only of the current
+     * element "." refers to the authorizable node itself.
+     * @return An iterator of property names available at the given {@code relPath}.
+     * @throws RepositoryException If an error occurs.
+     */
+    @Nonnull
     Iterator<String> getNames(String relPath) throws RepositoryException;
 
+    /**
+     * Returns {@code true} if there is a custom authorizable property at the
+     * specified {@code relPath}; false if no such property exists or if the
+     * path refers to a property located outside of the authorizable tree
+     * or a protected property that cannot be read/modified using
+     * the {@code AuthorizableProperties}.
+     *
+     * @param relPath A relative path to a property.
+     * @return {@code true} if a valid property exists; {@code false} otherwise.
+     * @throws RepositoryException If an error occurs.
+     */
     boolean hasProperty(String relPath) throws RepositoryException;
 
+    /**
+     * Returns the values of the property identified by the specified
+     * {@code relPath}. If no such property exists or the property doesn't
+     * represent a custom property associated with this authorizable {@code null}
+     * is returned.
+     *
+     * @param relPath A relative path to an authorizable property.
+     * @return The value(s) of the specified property or {@code null} if no
+     * such property exists or the property doesn't represent a valid authorizable
+     * property exposed by this interface.
+     * @throws RepositoryException If an error occurs.
+     */
+    @CheckForNull
     Value[] getProperty(String relPath) throws RepositoryException;
 
+    /**
+     * Creates or modifies the property at the specified {@code relPath}. If
+     * the property exists and is multi-valued it is converted into a single
+     * valued property.
+     *
+     * @param relPath A relative path referring to a custom authorizable property
+     * located underneath the associated authorizable.
+     * @param value The value of the property.
+     * @throws RepositoryException If the {@code relPath} refers to an invalid
+     * property: located outside of the scope of this authorizable or one
+     * that represents protected content that cannot be modified using this API.
+     * @see #setProperty(String, javax.jcr.Value[])
+     */
     void setProperty(String relPath, Value value) throws RepositoryException;
 
+    /**
+     * Creates or modifies the property at the specified {@code relPath}. If
+     * the property exists and is single-valued it is converted into a multi-
+     * value property.
+     *
+     * @param relPath A relative path referring to a custom authorizable property
+     * associated with the authorizable.
+     * @param values The values of the property.
+     * @throws RepositoryException If the {@code relPath} refers to an invalid
+     * property: located outside of the scope of this authorizable or one
+     * that represents protected content that cannot be modified using this API.
+     * @see #setProperty(String, javax.jcr.Value)
+     */
     void setProperty(String relPath, Value[] values) throws RepositoryException;
 
+    /**
+     * Removes the property identified by the given {@code relPath} and returns
+     * {@code true} if the property was successfully removed.
+     *
+     * @param relPath A relative path referring to a custom authorizable property
+     * associated with the authorizable.
+     * @return {@code true} if the property exists and could successfully be
+     * removed; {@code false} if no such property exists.
+     * @throws RepositoryException If the specified path points to a property
+     * that cannot be altered using this API because it is not associated with
+     * this authorizable or is otherwise considered protected.
+     */
     boolean removeProperty(String relPath) throws RepositoryException;
 
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/JcrAuthorizableProperties.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/JcrAuthorizableProperties.java?rev=1407114&r1=1407113&r2=1407114&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/JcrAuthorizableProperties.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/JcrAuthorizableProperties.java
Thu Nov  8 15:11:58 2012
@@ -36,13 +36,13 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * JcrAuthorizableProperty... TODO
+ * JCR level implementation of the internal {@code AuthorizableProperties}
+ * interface. It will be used whenever a {@code Session} is associated
+ * with a user manager and thus a JCR item operations can be used to retrieve
+ * the authorizable properties.
  */
 class JcrAuthorizableProperties implements AuthorizableProperties, UserConstants {
 
-    /**
-     * logger instance
-     */
     private static final Logger log = LoggerFactory.getLogger(JcrAuthorizableProperties.class);
 
     private final Node authorizableNode;
@@ -53,6 +53,7 @@ class JcrAuthorizableProperties implemen
         this.namePathMapper = namePathMapper;
     }
 
+    //---------------------------------------------< AuthorizableProperties >---
     @Override
     public Iterator<String> getNames(String relPath) throws RepositoryException {
         Node node = getNode();
@@ -161,6 +162,8 @@ class JcrAuthorizableProperties implemen
         return false;
     }
 
+    //------------------------------------------------------------< private >---
+
     private Node getNode() {
         return authorizableNode;
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/OakAuthorizableProperties.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/OakAuthorizableProperties.java?rev=1407114&r1=1407113&r2=1407114&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/OakAuthorizableProperties.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/OakAuthorizableProperties.java
Thu Nov  8 15:11:58 2012
@@ -39,13 +39,13 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * OakAuthorizableProperty... TODO
+ * Oak level implementation of the internal {@code AuthorizableProperties} that
+ * is used in those cases where no {@code Session} is associated with the
+ * {@code UserManager} and only OAK API methods can be used to read and
+ * modify authorizable properties.
  */
 class OakAuthorizableProperties implements AuthorizableProperties {
 
-    /**
-     * logger instance
-     */
     private static final Logger log = LoggerFactory.getLogger(OakAuthorizableProperties.class);
 
     private final UserProvider userProvider;
@@ -58,6 +58,7 @@ class OakAuthorizableProperties implemen
         this.namePathMapper = namePathMapper;
     }
 
+    //---------------------------------------------< AuthorizableProperties >---
     @Override
     public Iterator<String> getNames(String relPath) throws RepositoryException {
         checkRelativePath(relPath);
@@ -188,6 +189,8 @@ class OakAuthorizableProperties implemen
         return false;
     }
 
+    //------------------------------------------------------------< private >---
+
     private Tree getTree() {
         return userProvider.getAuthorizable(id);
     }
@@ -205,9 +208,8 @@ class OakAuthorizableProperties implemen
      * @return {@code true} if the given property is defined
      * by the rep:authorizable node type or one of it's sub-node types;
      * {@code false} otherwise.
-     * @throws RepositoryException If the property definition cannot be retrieved.
      */
-    private boolean isAuthorizableProperty(Tree authorizableTree, TreeLocation propertyLocation,
boolean verifyAncestor) throws RepositoryException {
+    private boolean isAuthorizableProperty(Tree authorizableTree, TreeLocation propertyLocation,
boolean verifyAncestor) {
         if (verifyAncestor && !Text.isDescendant(authorizableTree.getPath(), propertyLocation.getPath()))
{
                 log.debug("Attempt to access property outside of authorizable scope.");
                 return false;
@@ -217,7 +219,7 @@ class OakAuthorizableProperties implemen
 
     }
 
-    private boolean isAuthorizableProperty(Tree authorizableTree, PropertyState property)
throws RepositoryException {
+    private boolean isAuthorizableProperty(Tree authorizableTree, PropertyState property)
{
         // FIXME: add proper check for protection and declaring nt of the
         // FIXME: property using nt functionality provided by nt-plugins
         return isAuthorizableProperty(property.getName());

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserValidatorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserValidatorTest.java?rev=1407114&r1=1407113&r2=1407114&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserValidatorTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserValidatorTest.java
Thu Nov  8 15:11:58 2012
@@ -115,7 +115,7 @@ public class UserValidatorTest extends A
     public void createWithoutPrincipalName() throws Exception {
         try {
             User user = userMgr.createUser("withoutPrincipalName", "pw");
-            // TODO: use user.getPath instead (blocked by OAK-343)
+            // FIXME: use user.getPath instead (blocked by OAK-343)
             Tree tree = root.getTree("/rep:security/rep:authorizables/rep:users/t/te/test");
             tree.removeProperty(UserConstants.REP_PRINCIPAL_NAME);
             root.commit();
@@ -132,7 +132,7 @@ public class UserValidatorTest extends A
     public void createWithInvalidUUID() throws Exception {
         try {
             User user = userMgr.createUser("withInvalidUUID", "pw");
-            // TODO: use user.getPath instead (blocked by OAK-343)
+            // FIXME: use user.getPath instead (blocked by OAK-343)
             Tree tree = root.getTree("/rep:security/rep:authorizables/rep:users/t/te/test");
             tree.setProperty(JcrConstants.JCR_UUID, UUID.randomUUID().toString());
             root.commit();



Mime
View raw message